Skip to content

Commit

Permalink
Merge pull request #76 from SquirrelCorporation/fix-deletion-of-file
Browse files Browse the repository at this point in the history
BUGFIX - Fix deletion following refacto
  • Loading branch information
SquirrelDeveloper authored Jul 3, 2024
2 parents 68c9bfb + ef87703 commit 9fb0092
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ abstract class PlaybooksRepositoryComponent {
}

public fileBelongToRepository(path: string) {
logger.info(`rootPath: ${this.directory?.split('/')[0]} versus ${path.split('/')[0]}`);
this.childLogger.info(
`rootPath: ${this.directory?.split('/')[0]} versus ${path.split('/')[0]}`,
);
return this.directory?.split('/')[0] === path.split('/')[0];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ describe('PlaybooksRepositoryComponent', () => {
let playbooksRepositoryComponent: PlaybooksRepositoryComponent;

beforeEach(() => {
const logger = { child: vi.fn() };
const logger = {
child: () => {
return { info: vi.fn(), warn: vi.fn(), error: vi.fn() };
},
};
playbooksRepositoryComponent = new LocalRepositoryComponent('uuid', logger, 'name', 'path');
});

Expand Down
2 changes: 1 addition & 1 deletion server/src/use-cases/PlaybooksRepositoryUseCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async function deleteAnyInPlaybooksRepository(
if (!playbooksRepositoryComponent.fileBelongToRepository(fullPath)) {
throw new ForbiddenError('The selected path doesnt seems to belong to the repository');
}
Shell.FileSystemManager.createDirectory(fullPath, playbooksRepositoryComponent.rootPath);
Shell.FileSystemManager.deleteFiles(fullPath, playbooksRepositoryComponent.rootPath);
await playbooksRepositoryComponent.syncToDatabase();
}

Expand Down

0 comments on commit 9fb0092

Please sign in to comment.