Skip to content

Commit

Permalink
onlyoffice filename corrupted after editing (#686)
Browse files Browse the repository at this point in the history
Fix #683 

Filename handling is going to be worth a major refactor
  • Loading branch information
ericlinagora authored Oct 11, 2024
2 parents 4ccd193 + ed110a7 commit e2ac054
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions tdrive/backend/node/src/cli/cmds/editing_session_cmds/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ async function report(platform: TdrivePlatform, args: ListArguments) {
` - ${formatTS(version.date_added)} by ${await formatUser(version.creator_id)}`,
);
console.error(` - id: ${version.id}`);
if (dfile.name != version.filename)
console.error(` - filename: ${JSON.stringify(version.filename)}`);
if (dfile.name != version.file_metadata.name)
console.error(` - meta.name: ${JSON.stringify(version.file_metadata.name)}`);
console.error(
` - size: ${version.file_metadata.size} (${
version.file_metadata.size > previousSize ? "+" : ""
Expand Down
21 changes: 18 additions & 3 deletions tdrive/backend/node/src/services/documents/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,15 @@ export class DocumentsService {
}

if (file) {
const fileEntity = await globalResolver.services.files.save(null, file, options, context);
const fileEntity = await globalResolver.services.files.save(
null,
file,
{
...options,
filename: options.filename ?? driveFile.name,
},
context,
);

await globalResolver.services.documents.documents.createVersion(
driveFile.id,
Expand All @@ -1160,6 +1168,7 @@ export class DocumentsService {
file_metadata: {
external_id: fileEntity.id,
source: "internal",
name: file.filename ?? driveFile.name,
},
},
context,
Expand All @@ -1186,8 +1195,14 @@ export class DocumentsService {
)}`,
);
} catch (error) {
logger.error({ error: `${error}` }, "Failed to cancel editing Drive item");
CrudException.throwMe(error, new CrudException("Failed to cancel editing Drive item", 500));
logger.error(
{ error: `${error}` },
`Failed to ${keepEditing ? "update" : "end"} editing Drive item`,
);
CrudException.throwMe(
error,
new CrudException(`Failed to ${keepEditing ? "update" : "end"} editing Drive item`, 500),
);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export class DocumentsController {
totalChunks: parseInt(q.resumableTotalChunks || q.total_chunks) || 1,
totalSize: parseInt(q.resumableTotalSize || q.total_size) || 0,
chunkNumber: parseInt(q.resumableChunkNumber || q.chunk_number) || 1,
filename: q.resumableFilename || q.filename || file?.filename || undefined,
filename: q.filename || undefined,
type: q.resumableType || q.type || file?.mimetype || undefined,
waitForThumbnail: !!q.thumbnail_sync,
ignoreThumbnails: false,
Expand Down

0 comments on commit e2ac054

Please sign in to comment.