🩹 backend,oo: minor fixes for file renames (#525)

This commit is contained in:
Eric Doughty-Papassideris
2024-09-19 21:55:35 +02:00
parent 5285de4abf
commit a40cb7eae6
3 changed files with 15 additions and 4 deletions
@@ -549,7 +549,7 @@ export class DocumentsService {
} }
const updatable = ["access_info", "name", "tags", "parent_id", "description", "is_in_trash"]; const updatable = ["access_info", "name", "tags", "parent_id", "description", "is_in_trash"];
let renamedTo: string | undefined;
for (const key of updatable) { for (const key of updatable) {
if ((content as any)[key]) { if ((content as any)[key]) {
if ( if (
@@ -590,7 +590,7 @@ export class DocumentsService {
} }
}); });
} else if (key === "name") { } else if (key === "name") {
item.name = await getItemName( renamedTo = item.name = await getItemName(
content.parent_id || item.parent_id, content.parent_id || item.parent_id,
item.id, item.id,
content.name, content.name,
@@ -621,7 +621,17 @@ export class DocumentsService {
await updateItemSize(oldParent, this.repository, context); 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) { if (item.parent_id === this.TRASH) {
//When moving to trash we recompute the access level to make them flat //When moving to trash we recompute the access level to make them flat
item.access_info = await makeStandaloneAccessLevel( item.access_info = await makeStandaloneAccessLevel(
@@ -89,7 +89,7 @@ class BrowserEditorController {
drive_file_id, drive_file_id,
editing_session_key: editingSessionKey, editing_session_key: editingSessionKey,
file_id: file.id, file_id: file.id,
file_name: file.filename || file?.metadata?.name || '', file_name: driveFile?.item?.name || file.filename || file.metadata?.name || '',
preview: !!preview, preview: !!preview,
} as OfficeToken, } as OfficeToken,
CREDENTIALS_SECRET, CREDENTIALS_SECRET,
@@ -1,6 +1,7 @@
export type DriveFileType = { export type DriveFileType = {
access: 'manage' | 'write' | 'read' | 'none'; access: 'manage' | 'write' | 'read' | 'none';
item: { item: {
name: string;
last_version_cache: { last_version_cache: {
id: string; id: string;
date_added: number; date_added: number;