Skip to content

Commit

Permalink
fix: importing model fresh install (#1133)
Browse files Browse the repository at this point in the history
Signed-off-by: axel7083 <[email protected]>
  • Loading branch information
axel7083 authored May 30, 2024
1 parent 26454aa commit 4441e14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/backend/src/managers/catalogManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ vi.mock('node:fs', () => {
readFile: vi.fn(),
stat: vi.fn(),
writeFile: vi.fn(),
mkdir: vi.fn(),
},
};
});
Expand Down Expand Up @@ -183,6 +184,7 @@ test('expect to call writeFile in addLocalModelsToCatalog with catalog updated',
},
]);

expect(promises.mkdir).toHaveBeenCalled();
expect(writeFileMock).toBeCalledWith('path', JSON.stringify(updatedCatalog, undefined, 2), 'utf-8');
});

Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/managers/catalogManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ export class CatalogManager extends Publisher<ApplicationCatalog> implements Dis
// Add all our models infos to the user's models catalog
content.models.push(...models);

// ensure parent directory exists
await promises.mkdir(path.dirname(userCatalogPath), { recursive: true });

// overwrite the existing catalog
return promises.writeFile(userCatalogPath, JSON.stringify(content, undefined, 2), 'utf-8');
}
Expand Down

0 comments on commit 4441e14

Please sign in to comment.