From b0c9f0d38dc0c1f8d00630bd5591de103d8a5674 Mon Sep 17 00:00:00 2001 From: Dan Schultz Date: Thu, 9 Nov 2023 13:20:35 -0500 Subject: [PATCH 1/2] Fix casing typo --- src/classes/PermanentFileSystem.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/classes/PermanentFileSystem.ts b/src/classes/PermanentFileSystem.ts index 0b6dc068..98293ffd 100644 --- a/src/classes/PermanentFileSystem.ts +++ b/src/classes/PermanentFileSystem.ts @@ -238,7 +238,7 @@ export class PermanentFileSystem { contentType: 'application/octet-stream', size, }; - const archiveRecordfragment = { + const archiveRecordFragment = { displayName: archiveRecordName, fileSystemCompatibleName: archiveRecordName, }; @@ -246,14 +246,14 @@ export class PermanentFileSystem { await this.getClientConfiguration(), dataStream, fileFragment, - archiveRecordfragment, + archiveRecordFragment, parentFolder, ); await createArchiveRecord( await this.getClientConfiguration(), s3Url, fileFragment, - archiveRecordfragment, + archiveRecordFragment, parentFolder, ); } From 4436b1ab4a18d787eb622f416de2a296f995b285 Mon Sep 17 00:00:00 2001 From: Dan Schultz Date: Thu, 9 Nov 2023 13:20:45 -0500 Subject: [PATCH 2/2] Update caches on creation We were not updating our local caches when items were created; this was not resulting in functional issues because of our cache-busting logic, but it was resulting in non-optimal caching and an increase in API calls as a result of being unable to rely on the cache. Specifically, rclone verifies files immediately after creation by checking their stats. This meant that every time a file was uploaded it would result in a preventable API call to `/folder/getWithChildren`. There were some circumstances where a similar unnecessary call could happen after folder creation. Issue #306 Update cache after file / folder creation --- src/classes/PermanentFileSystem.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/classes/PermanentFileSystem.ts b/src/classes/PermanentFileSystem.ts index 98293ffd..9a74ac8a 100644 --- a/src/classes/PermanentFileSystem.ts +++ b/src/classes/PermanentFileSystem.ts @@ -178,7 +178,7 @@ export class PermanentFileSystem { return []; } - public async createDirectory(requestedPath: string): Promise { + public async createDirectory(requestedPath: string): Promise { if (isRootPath(requestedPath)) { throw new InvalidOperationForPathError('You cannot create new root level folders via SFTP.'); } @@ -191,13 +191,15 @@ export class PermanentFileSystem { const parentPath = path.dirname(requestedPath); const childName = path.basename(requestedPath); const parentFolder = await this.loadFolder(parentPath); - return createFolder( + const newFolder = await createFolder( await this.getClientConfiguration(), { name: childName, }, parentFolder, ); + parentFolder.folders.push(newFolder); + this.folderCache.set(parentPath, parentFolder); } public async deleteDirectory(requestedPath: string): Promise { @@ -249,13 +251,15 @@ export class PermanentFileSystem { archiveRecordFragment, parentFolder, ); - await createArchiveRecord( + const newArchiveRecord = await createArchiveRecord( await this.getClientConfiguration(), s3Url, fileFragment, archiveRecordFragment, parentFolder, ); + parentFolder.archiveRecords.push(newArchiveRecord); + this.folderCache.set(parentPath, parentFolder); } public async deleteFile(requestedPath: string): Promise {