Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class LocalStorage extends StorageConnector {
private findStorageFolder(folder) {
let _storageFolder = folder;

if (fs.existsSync(_storageFolder)) {
if (_storageFolder && fs.existsSync(_storageFolder)) {
return _storageFolder;
}

Expand Down
5 changes: 5 additions & 0 deletions packages/core/tests/unit/005-Storage/LocalStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const testOriginalMetadata = {
};

describe('Local Storage Tests', () => {
it('Initializes with undefined folder without crashing (guard)', () => {
expect(() => new LocalStorage()).not.toThrow();
expect(() => new LocalStorage({} as any)).not.toThrow();
expect(() => new LocalStorage({ folder: undefined } as any)).not.toThrow();
});
it('Get Default Storage instance', async () => {
const localStorage: StorageConnector = ConnectorService.getStorageConnector();

Expand Down
5 changes: 2 additions & 3 deletions packages/sdk/src/Storage/StorageInstance.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,10 @@ export class StorageInstance extends SDKObject {
* @param resourceName - The name or smythfs:// uri of the resource to check
* @returns true if the resource exists, false otherwise
*/
async exists(resourceName: string) {
async exists(resourceName: string): Promise<boolean> {
const uri = resourceName.startsWith('smythfs://') ? resourceName : await this.getResourceUri(resourceName);
try {
await this.fs.exists(uri, this._candidate);
return uri;
return await this.fs.exists(uri, this._candidate);
} catch (error) {
console.error(error);
throw error;
Expand Down