Skip to content

Commit

Permalink
fix: epom cache was never updated (#681)
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Zhang <yanzh@microsoft.com>
  • Loading branch information
Eskibear committed Jul 28, 2021
1 parent a5fdd7d commit 695d35f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
9 changes: 1 addition & 8 deletions src/explorer/EffectivePomProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
Expand Down Expand Up @@ -65,10 +62,6 @@ export class EffectivePomProvider {
return promise;
}

if (this.effectivePom !== undefined) {
return this.effectivePom;
}

this.calculateEffectivePom(options).catch(console.error);
return promise;
}
Expand Down
7 changes: 4 additions & 3 deletions src/utils/mavenUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit 695d35f

Please sign in to comment.