fix(pdf): use UUID-only backup filename to avoid NAME_MAX overflow - #294
Conversation
When saving files with very long filenames (especially with CJK
characters that expand in UTF-8), the backup path
".{filename}.backup.{uuid}" could exceed the filesystem's
NAME_MAX limit of 255 bytes per path component, causing save
failures. Use a UUID-only hidden filename (".{uuid}") as backup,
which is always 39 bytes and avoids the issue entirely.
使用纯UUID作为备份文件名,避免超长文件名导致的NAME_MAX溢出问题。
当保存带有超长文件名(特别是CJK字符在UTF-8中占多字节)的文件时,
原有的备份路径".{filename}.backup.{uuid}"可能超过文件系统的
NAME_MAX限制(255字节),导致保存失败。改为仅使用UUID作为隐藏
备份文件名(".{uuid}"),固定39字节,彻底避免此问题。
Log: 修复超长文件名保存失败问题
PMS: BUG-370563
Influence: 修复后带有超长文件名的PDF文档编辑后可正常保存,中英文混合文件名也能正常处理。
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已足够完善,无需进一步修改 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts PDF saving logic to use brace-less UUID filenames for temporary and backup files, ensuring hidden backup names no longer depend on potentially overlong original filenames and thus avoid filesystem NAME_MAX overflows, while updating the file copyright range. Sequence diagram for updated DPdfDoc::save temporary and backup filename handlingsequenceDiagram
actor User
participant DPdfDoc
participant QTemporaryDir
participant QUuid
participant QFileInfo
participant QFile
User->>DPdfDoc: save()
DPdfDoc->>QTemporaryDir: QTemporaryDir()
DPdfDoc->>QUuid: createUuid()
QUuid-->>DPdfDoc: uuid
DPdfDoc->>QUuid: toString(WithoutBraces)
QUuid-->>DPdfDoc: tempUuidString
DPdfDoc->>DPdfDoc: build tempFilePath from tempDir.path() and tempUuidString
DPdfDoc->>DPdfDoc: targetPath = d_func()->m_filePath
DPdfDoc->>QFileInfo: QFileInfo(targetPath)
QFileInfo-->>DPdfDoc: fileInfo
DPdfDoc->>fileInfo: absolutePath()
fileInfo-->>DPdfDoc: dirPath
DPdfDoc->>QUuid: createUuid()
QUuid-->>DPdfDoc: backupUuid
DPdfDoc->>QUuid: toString(WithoutBraces)
QUuid-->>DPdfDoc: backupUuidString
DPdfDoc->>DPdfDoc: build backupPath as dirPath + "/." + backupUuidString
DPdfDoc->>QFile: QFile(targetPath)
DPdfDoc->>QFile: rename(targetPath, backupPath)
DPdfDoc->>QFile: saveWriter.write(tempFilePath, targetPath)
DPdfDoc-->>User: return true/false
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
When saving files with very long filenames (especially with CJK characters that expand in UTF-8), the backup path
".{filename}.backup.{uuid}" could exceed the filesystem's NAME_MAX limit of 255 bytes per path component, causing save failures. Use a UUID-only hidden filename (".{uuid}") as backup, which is always 39 bytes and avoids the issue entirely.
使用纯UUID作为备份文件名,避免超长文件名导致的NAME_MAX溢出问题。
当保存带有超长文件名(特别是CJK字符在UTF-8中占多字节)的文件时,
原有的备份路径".{filename}.backup.{uuid}"可能超过文件系统的
NAME_MAX限制(255字节),导致保存失败。改为仅使用UUID作为隐藏
备份文件名(".{uuid}"),固定39字节,彻底避免此问题。
Log: 修复超长文件名保存失败问题
PMS: BUG-370563
Influence: 修复后带有超长文件名的PDF文档编辑后可正常保存,中英文混合文件名也能正常处理。
Summary by Sourcery
Ensure PDF saving uses UUID-only temporary and backup filenames to avoid filesystem NAME_MAX overflows with very long filenames.
Bug Fixes:
Enhancements: