Skip to content

Commit

Permalink
fix(synchronizer): make sure proper empty data is returned
Browse files Browse the repository at this point in the history
  • Loading branch information
f1ames committed Feb 5, 2024
1 parent 5a33e0a commit 11c6518
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/synchronizer/src/utils/projectSynchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {normalize} from 'path';
import {StorageHandlerPolicy, StoragePolicyFormat} from '../handlers/storageHandlerPolicy.js';
import {ApiHandler} from '../handlers/apiHandler.js';
import {GitHandler} from '../handlers/gitHandler.js';
import type {ApiProjectDetailsData, ApiUserProject} from '../handlers/apiHandler.js';
import type {ApiProjectDetailsData, ApiProjectPermissions, ApiUserProject} from '../handlers/apiHandler.js';
import type {TokenInfo} from '../handlers/storageHandlerAuth.js';
import type {RepoRemoteInputData} from './synchronizer.js';
import type {ProjectInfo, RepoRemoteInputData} from './synchronizer.js';

export class ProjectSynchronizer extends EventEmitter {
private _dataCache: Record<string, ApiProjectDetailsData['data']['getProject']> = {};
Expand All @@ -20,7 +20,7 @@ export class ProjectSynchronizer extends EventEmitter {
super();
}

getProjectInfo(rootPath: string, projectSlug?: string) {
getProjectInfo(rootPath: string, projectSlug?: string): ProjectInfo | undefined {
const cached = this._dataCache[this.getCacheId(rootPath, projectSlug)];

return cached ? {
Expand All @@ -30,7 +30,7 @@ export class ProjectSynchronizer extends EventEmitter {
} : undefined;
}

getProjectPermissions(rootPath: string, projectSlug?: string) {
getProjectPermissions(rootPath: string, projectSlug?: string): ApiProjectPermissions | undefined {
return this._dataCache[this.getCacheId(rootPath, projectSlug)]?.permissions;
}

Expand All @@ -57,11 +57,15 @@ export class ProjectSynchronizer extends EventEmitter {
};
}

return undefined;
return {
valid: false,
path: '',
policy: undefined,
};
}

getRepositorySuppressions(rootPath: string, projectSlug?: string) {
return this._dataCache[this.getCacheId(rootPath, projectSlug)]?.projectRepository.suppressions;
return this._dataCache[this.getCacheId(rootPath, projectSlug)]?.projectRepository.suppressions ?? [];
}

async synchronize(tokenInfo: TokenInfo, rootPath: string, projectSlug?: string): Promise<void> {
Expand Down

0 comments on commit 11c6518

Please sign in to comment.