fix: epom cache was never updated (#681)

Signed-off-by: Yan Zhang <yanzh@microsoft.com>
This commit is contained in:
Yan Zhang 2021-07-28 15:11:32 +08:00 коммит произвёл GitHub
Родитель a5fdd7d83b
Коммит 695d35f48a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 5 добавлений и 11 удалений

Просмотреть файл

@ -8,18 +8,15 @@ import { IEffectivePom } from "./model/IEffectivePom";
export class EffectivePomProvider {
private pomPath: string;
private effectivePom: IEffectivePom;
private emitter: EventEmitter = new EventEmitter();
private isCalculating: boolean = false;
constructor(pomPath: string) {
this.pomPath = pomPath;
this.emitter.on("complete", (resp: IEffectivePom) => {
this.effectivePom = resp;
this.emitter.on("complete", (_resp: IEffectivePom) => {
this.isCalculating = false;
});
this.emitter.on("error", (_error) => {
this.effectivePom = { pomPath };
this.isCalculating = false;
});
}
@ -65,10 +62,6 @@ export class EffectivePomProvider {
return promise;
}
if (this.effectivePom !== undefined) {
return this.effectivePom;
}
this.calculateEffectivePom(options).catch(console.error);
return promise;
}

Просмотреть файл

@ -24,18 +24,19 @@ import { updateLRUCommands } from "./historyUtils";
*/
export async function rawEffectivePom(pomPath: string, options?: {cacheOnly?: boolean}): Promise<string | undefined> {
const outputPath: string = getTempFolder(pomPath);
const epomPath: string = `${outputPath}.epom`;
const mtimePath: string = `${outputPath}.mtime`;
const cachedMTimeMs: string | undefined = await readFileIfExists(mtimePath);
const stat: fse.Stats = await fse.stat(pomPath);
const mtimeMs: string = stat.mtimeMs.toString();
if (cachedMTimeMs === mtimeMs || options?.cacheOnly) {
return await readFileIfExists(outputPath);
return await readFileIfExists(epomPath);
}
await executeInBackground(`help:effective-pom -Doutput="${outputPath}"`, pomPath);
await executeInBackground(`help:effective-pom -Doutput="${epomPath}"`, pomPath);
await fse.writeFile(mtimePath, mtimeMs);
return await readFileIfExists(outputPath);
return await readFileIfExists(epomPath);
}
export async function rawDependencyTree(pomPath: string): Promise<any> {