From 7a0d729401bb4b18556f9a855ec1dc93207eef53 Mon Sep 17 00:00:00 2001 From: f1ames Date: Wed, 7 Feb 2024 14:36:06 +0100 Subject: [PATCH] feat: add force synchronize method --- packages/synchronizer/src/utils/projectSynchronizer.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/synchronizer/src/utils/projectSynchronizer.ts b/packages/synchronizer/src/utils/projectSynchronizer.ts index bb523144..68c55752 100644 --- a/packages/synchronizer/src/utils/projectSynchronizer.ts +++ b/packages/synchronizer/src/utils/projectSynchronizer.ts @@ -199,6 +199,12 @@ export class ProjectSynchronizer extends EventEmitter { } } + async forceSynchronize(tokenInfo: TokenInfo, rootPath: string, projectSlug?: string): Promise { + 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, @@ -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'); }