Skip to content

Commit

Permalink
fix(synchronizer): make sure toggleSuppression does not file on readi…
Browse files Browse the repository at this point in the history
…ng existing ones
  • Loading branch information
f1ames committed Feb 11, 2024
1 parent f2d4226 commit 5eb49ac
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/synchronizer/src/utils/projectSynchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,19 @@ export class ProjectSynchronizer extends EventEmitter {

const suppressionResult = await this._apiHandler.toggleSuppression(fingerprint, id, description, location, tokenInfo);
if (suppressionResult?.data?.toggleSuppression) {
const existingSuppressions = await this.readSuppressions(repoData);
const allSuppressions = this.mergeSuppressions(existingSuppressions, [suppressionResult?.data?.toggleSuppression]);
await this.storeSuppressions(allSuppressions, repoData);
let existingSuppressions: ApiSuppression[] = [];
try {
existingSuppressions = await this.readSuppressions(repoData);
} catch (err) {
existingSuppressions = this.getRepositorySuppressions(rootPath, projectSlug);
}
const allSuppressions = this.mergeSuppressions(existingSuppressions, [suppressionResult?.data?.toggleSuppression]);
await this.storeSuppressions(allSuppressions, repoData);

const cacheId = this.getCacheId(rootPath, projectSlug);
if (this._dataCache[cacheId]) {
this._dataCache[cacheId].suppressions = allSuppressions;
}
const cacheId = this.getCacheId(rootPath, projectSlug);
if (this._dataCache[cacheId]) {
this._dataCache[cacheId].suppressions = allSuppressions;
}
}
}

Expand Down

0 comments on commit 5eb49ac

Please sign in to comment.