Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: epom cache was never updated #681

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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