"use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});const fs_extra_1=__importDefault(require("fs-extra")),path_1=__importDefault(require("path")),common_1=require("../config/common");class StorageUtils{constructor(){this.refreshPath()}get(t){return fs_extra_1.default.readJSONSync(this.file)[t]}set(t,e){const r=fs_extra_1.default.readJSONSync(this.file);void 0===e?delete r[t]:r[t]=e,fs_extra_1.default.writeJSONSync(this.file,r)}getRootPath(){return this.rootPath}refreshPath(){if(this.rootPath=common_1.configManager.config.CacheRoot,this.file=path_1.default.join(this.rootPath,common_1.configManager.config.storageFile),fs_extra_1.default.ensureDirSync(this.rootPath),fs_extra_1.default.existsSync(this.file))try{fs_extra_1.default.readJSONSync(this.file)}catch(t){console.log(t),fs_extra_1.default.writeJSONSync(this.file,{})}else fs_extra_1.default.writeJSONSync(this.file,{})}}exports.default=StorageUtils;