Skip to content

Commit

Permalink
🩹 backend,oo: minor fixes for file renames (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlinagora committed Sep 19, 2024
1 parent 5285de4 commit a40cb7e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
16 changes: 13 additions & 3 deletions tdrive/backend/node/src/services/documents/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ export class DocumentsService {
}

const updatable = ["access_info", "name", "tags", "parent_id", "description", "is_in_trash"];

let renamedTo: string | undefined;
for (const key of updatable) {
if ((content as any)[key]) {
if (
Expand Down Expand Up @@ -590,7 +590,7 @@ export class DocumentsService {
}
});
} else if (key === "name") {
item.name = await getItemName(
renamedTo = item.name = await getItemName(
content.parent_id || item.parent_id,
item.id,
content.name,
Expand Down Expand Up @@ -621,7 +621,17 @@ export class DocumentsService {

await updateItemSize(oldParent, this.repository, context);
}

if (renamedTo && item.editing_session_key)
ApplicationsApiService.getDefault()
.renameEditingKeyFilename(item.editing_session_key, renamedTo)
.catch(err => {
logger.error("Error rename editing session to new name", {
err,
editing_session_key: item.editing_session_key,
renamedTo,
});
/* Ignore errors, just throw it out there... */
});
if (item.parent_id === this.TRASH) {
//When moving to trash we recompute the access level to make them flat
item.access_info = await makeStandaloneAccessLevel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class BrowserEditorController {
drive_file_id,
editing_session_key: editingSessionKey,
file_id: file.id,
file_name: file.filename || file?.metadata?.name || '',
file_name: driveFile?.item?.name || file.filename || file.metadata?.name || '',
preview: !!preview,
} as OfficeToken,
CREDENTIALS_SECRET,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type DriveFileType = {
access: 'manage' | 'write' | 'read' | 'none';
item: {
name: string;
last_version_cache: {
id: string;
date_added: number;
Expand Down

0 comments on commit a40cb7e

Please sign in to comment.