Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update caches on item creation #307

Merged
merged 2 commits into from
Nov 14, 2023
Merged
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
16 changes: 10 additions & 6 deletions src/classes/PermanentFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class PermanentFileSystem {
return [];
}

public async createDirectory(requestedPath: string): Promise<Folder> {
public async createDirectory(requestedPath: string): Promise<void> {
if (isRootPath(requestedPath)) {
throw new InvalidOperationForPathError('You cannot create new root level folders via SFTP.');
}
Expand All @@ -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<void> {
Expand Down Expand Up @@ -238,24 +240,26 @@ export class PermanentFileSystem {
contentType: 'application/octet-stream',
size,
};
const archiveRecordfragment = {
const archiveRecordFragment = {
displayName: archiveRecordName,
fileSystemCompatibleName: archiveRecordName,
};
const s3Url = await uploadFile(
await this.getClientConfiguration(),
dataStream,
fileFragment,
archiveRecordfragment,
archiveRecordFragment,
parentFolder,
);
await createArchiveRecord(
const newArchiveRecord = await createArchiveRecord(
await this.getClientConfiguration(),
s3Url,
fileFragment,
archiveRecordfragment,
archiveRecordFragment,
parentFolder,
);
parentFolder.archiveRecords.push(newArchiveRecord);
this.folderCache.set(parentPath, parentFolder);
}

public async deleteFile(requestedPath: string): Promise<void> {
Expand Down