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ACF;;AA9D2B;;;AACrB,iBAAA,CAAA,OAAA,GAAkB,GAAlB;;AAgEF,eAAe,MAAf,CAAsB,IAAtB,EAAkC,KAAlC,EAAsD;AAC3D;AACA,OAAK,MAAM,OAAX,IAAsB,MAAM,uBAAgB,GAAhB,CAAoB,KAApB,EAA2B,EAAE,IAAI,yBAAS,EAAT,CAAjC,CAA5B,EAA4E;AAC1E,IAAA,IAAI,CAAC,MAAL,CAAY,OAAZ;AACD;;AAED,EAAA,IAAI,CAAC,MAAL,CAAY,iBAAiB,CAAC,OAA9B;AACA,SAAO,IAAI,CAAC,MAAL,CAAY,QAAZ,CAAP;AACD,C","sourcesContent":["import BluebirdPromise from \"bluebird-lst\"\nimport { Arch, log } from \"builder-util\"\nimport { copyFile } from \"builder-util/out/fs\"\nimport { orNullIfFileNotExist } from \"builder-util/out/promise\"\nimport { Hash } from \"crypto\"\nimport { ensureDir, readFile, readJson, writeJson } from \"fs-extra\"\nimport * as path from \"path\"\n\nexport interface BuildCacheInfo {\n executableDigest: string\n}\n\nexport class BuildCacheManager {\n static VERSION: string = \"0\"\n\n readonly cacheDir: string\n readonly cacheInfoFile: string\n readonly cacheFile: string\n\n cacheInfo: BuildCacheInfo | null = null\n\n private newDigest: string | null = null\n\n constructor(outDir: string, private readonly executableFile: string, arch: Arch) {\n this.cacheDir = path.join(outDir, \".cache\", Arch[arch])\n this.cacheFile = path.join(this.cacheDir, \"app.exe\")\n this.cacheInfoFile = path.join(this.cacheDir, \"info.json\")\n }\n\n async copyIfValid(digest: string): Promise<boolean> {\n this.newDigest = digest\n\n this.cacheInfo = await orNullIfFileNotExist(readJson(this.cacheInfoFile))\n const oldDigest = this.cacheInfo == null ? null : this.cacheInfo.executableDigest\n if (oldDigest !== digest) {\n log.debug({oldDigest, newDigest: digest}, \"no valid cached executable found\")\n return false\n }\n\n log.debug({cacheFile: this.cacheFile, file: this.executableFile}, `copying cached executable`)\n try {\n await copyFile(this.cacheFile, this.executableFile, false)\n return true\n }\n catch (e) {\n if (e.code === \"ENOENT\" || e.code === \"ENOTDIR\") {\n log.debug(
|