fix(build): migrate project tooling and filesystem integration to current smartfs-based stack
This commit is contained in:
@@ -38,43 +38,48 @@ export class CacheDiskManager extends AbstractCache {
|
||||
);
|
||||
}
|
||||
if (this.status === 'active') {
|
||||
plugins.smartfile.fs.ensureDirSync(this.fsPath);
|
||||
await plugins.fs.directory(this.fsPath).recursive().create();
|
||||
}
|
||||
this.readyDeferred.resolve();
|
||||
}
|
||||
|
||||
public async retrieveCacheEntryByKey(keyArg: string): Promise<CacheEntry> {
|
||||
const fileString = await plugins.smartfile.fs.toStringSync(
|
||||
plugins.path.join(this.fsPath, encodeURIComponent(keyArg)),
|
||||
);
|
||||
const fileString = (await plugins.fs
|
||||
.file(plugins.path.join(this.fsPath, encodeURIComponent(keyArg)))
|
||||
.encoding('utf8')
|
||||
.read()) as string;
|
||||
return CacheEntry.fromStorageJsonString(fileString);
|
||||
}
|
||||
|
||||
public async storeCacheEntryByKey(keyArg: string, cacheEntryArg: CacheEntry) {
|
||||
await plugins.smartfile.memory.toFs(
|
||||
cacheEntryArg.foldToJson(),
|
||||
plugins.path.join(this.fsPath, encodeURIComponent(keyArg)),
|
||||
);
|
||||
await plugins.fs
|
||||
.file(plugins.path.join(this.fsPath, encodeURIComponent(keyArg)))
|
||||
.write(cacheEntryArg.foldToJson());
|
||||
}
|
||||
|
||||
public async checkKeyPresence(keyArg: string): Promise<boolean> {
|
||||
return plugins.smartfile.fs.isFile(
|
||||
plugins.path.join(this.fsPath, encodeURIComponent(keyArg)),
|
||||
);
|
||||
return plugins.fs
|
||||
.file(plugins.path.join(this.fsPath, encodeURIComponent(keyArg)))
|
||||
.exists();
|
||||
}
|
||||
|
||||
public async deleteCacheEntryByKey(keyArg: string) {
|
||||
await plugins.smartfile.fs.remove(
|
||||
const cacheFile = plugins.fs.file(
|
||||
plugins.path.join(this.fsPath, encodeURIComponent(keyArg)),
|
||||
);
|
||||
if (await cacheFile.exists()) {
|
||||
await cacheFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public async cleanOutdated() {}
|
||||
|
||||
public async cleanAll() {
|
||||
if (this.status === 'active') {
|
||||
if (plugins.smartfile.fs.isDirectory(this.fsPath)) {
|
||||
await plugins.smartfile.fs.ensureEmptyDir(this.fsPath);
|
||||
const dir = plugins.fs.directory(this.fsPath);
|
||||
if (await dir.exists()) {
|
||||
await plugins.fs.directory(this.fsPath).recursive().delete();
|
||||
await plugins.fs.directory(this.fsPath).recursive().create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user