Skip to content

Commit

Permalink
feat: add force synchronize method
Browse files Browse the repository at this point in the history
  • Loading branch information
f1ames committed Feb 7, 2024
1 parent f1b9029 commit 7a0d729
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/synchronizer/src/utils/projectSynchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ export class ProjectSynchronizer extends EventEmitter {
}
}

async forceSynchronize(tokenInfo: TokenInfo, rootPath: string, projectSlug?: string): Promise<void> {
const repoData = await this.getRootGitData(rootPath);
await this.dropCacheMetadata(repoData);
return this.synchronize(tokenInfo, rootPath, projectSlug);
}

private async refetchProjectDetails(repoData: RepoRemoteInputData, ownerProjectSlug: string, tokenInfo: TokenInfo) {
return this._apiHandler.getProjectDetails({
slug: ownerProjectSlug,
Expand Down Expand Up @@ -324,6 +330,10 @@ export class ProjectSynchronizer extends EventEmitter {
return (await this._storageHandlerJsonCache.getStoreData(this.getMetadataFileName(repoData)) ?? {}) as CacheMetadata;
}

private async dropCacheMetadata(repoData: RepoRemoteInputData) {
return this._storageHandlerJsonCache.emptyStoreData(this.getMetadataFileName(repoData));
}

private getPolicyFileName(repoData: RepoRemoteInputData) {
return this.getFileName(repoData, 'policy');
}
Expand Down

0 comments on commit 7a0d729

Please sign in to comment.