From a3a1714e8612ee68abf9aef3de96b640d1cc0504 Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Mon, 20 Jul 2026 09:12:05 +0800 Subject: [PATCH] fix(pdf): use UUID-only backup filename to avoid NAME_MAX overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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文档编辑后可正常保存,中英文混合文件名也能正常处理。 --- 3rdparty/deepin-pdfium/src/dpdfdoc.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/3rdparty/deepin-pdfium/src/dpdfdoc.cpp b/3rdparty/deepin-pdfium/src/dpdfdoc.cpp index 2e593bba..c83e67b1 100755 --- a/3rdparty/deepin-pdfium/src/dpdfdoc.cpp +++ b/3rdparty/deepin-pdfium/src/dpdfdoc.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later @@ -245,7 +245,7 @@ bool DPdfDoc::save() QTemporaryDir tempDir; - QString tempFilePath = tempDir.path() + "/" + QUuid::createUuid().toString(); + QString tempFilePath = tempDir.path() + "/" + QUuid::createUuid().toString(QUuid::WithoutBraces); saveWriter.setFileName(tempFilePath); @@ -269,9 +269,10 @@ bool DPdfDoc::save() QString targetPath = d_func()->m_filePath; - // Extract directory and filename to create hidden backup file + // Use a UUID-only hidden file as backup to avoid long filename + // issues with NAME_MAX (255 bytes) on the backup path. QFileInfo fileInfo(targetPath); - QString backupPath = fileInfo.absolutePath() + "/." + fileInfo.fileName() + ".backup." + QUuid::createUuid().toString(); + QString backupPath = fileInfo.absolutePath() + "/." + QUuid::createUuid().toString(QUuid::WithoutBraces); QFile targetFile(targetPath);