Make cache method public

Reviewed By: jeanlauliac

Differential Revision: D5804391

fbshipit-source-id: 8da732a440111ca5d89d51fa9e4c2727d386bbff
This commit is contained in:
Miguel Jimenez Esun 2017-09-12 07:55:31 -07:00 committed by Facebook Github Bot
parent 5fa193bdee
commit 090df5c104
1 changed files with 9 additions and 9 deletions

View File

@ -153,6 +153,14 @@ class FileBasedCache {
return result; return result;
} }
resetCache(reporter: Reporter) {
rimraf.sync(path.join(this._rootPath, 'last_collected'));
rimraf.sync(path.join(this._rootPath, 'cache'));
reporter.update({type: 'transform_cache_reset'});
this._cacheWasReset = true;
this._lastCollected = Date.now();
}
/** /**
* We verify the source hash matches to ensure we always favor rebuilding when * We verify the source hash matches to ensure we always favor rebuilding when
* source change (rather than just using fs.mtime(), a bit less robust). * source change (rather than just using fs.mtime(), a bit less robust).
@ -217,7 +225,7 @@ class FileBasedCache {
*/ */
_collectIfNecessarySync(options: CacheOptions) { _collectIfNecessarySync(options: CacheOptions) {
if (options.resetCache && !this._cacheWasReset) { if (options.resetCache && !this._cacheWasReset) {
this._resetCache(options.reporter); this.resetCache(options.reporter);
return; return;
} }
const lastCollected = this._lastCollected; const lastCollected = this._lastCollected;
@ -229,14 +237,6 @@ class FileBasedCache {
} }
} }
_resetCache(reporter: Reporter) {
rimraf.sync(path.join(this._rootPath, 'last_collected'));
rimraf.sync(path.join(this._rootPath, 'cache'));
reporter.update({type: 'transform_cache_reset'});
this._cacheWasReset = true;
this._lastCollected = Date.now();
}
/** /**
* We want to avoid preventing tool use if the cleanup fails for some reason, * We want to avoid preventing tool use if the cleanup fails for some reason,
* but still provide some chance for people to report/fix things. * but still provide some chance for people to report/fix things.