Skip to content

Commit 2709c79

Browse files
pppanghu77deepin-bot[bot]
authored andcommitted
fix: Temporarily disable QSaveFile in TextFileSaver
Commented out QSaveFile usage in the save method due to issues with file permissions in certain cases. The code now directly uses QFile for saving files. This change is intended to address potential problems with long filenames and ensure smoother file saving operations. Log: Temporarily disable QSaveFile in TextFileSaver to prevent permission issues. Bug: https://pms.uniontech.com/bug-view-327987.html
1 parent 0150124 commit 2709c79

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

src/common/text_file_saver.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,27 @@ bool TextFileSaver::save()
6363
return false;
6464
}
6565

66+
// TODO: 暂时禁用QSaveFile,后续再考虑, 因为QSaveFile在某些情况下会修改文件所属权限
6667
// WARNING: For long filenames (>245 chars), QSaveFile may create temporary files
6768
// with names that exceed system limits. TextFileSaver handles this internally.
68-
QFileInfo fileInfo(m_filePath);
69-
bool disableSaveProtect = fileInfo.fileName().length() > MAX_FILENAME_LENGTH;
70-
71-
if (!disableSaveProtect) {
72-
QSaveFile saveFile(m_filePath);
73-
saveFile.setDirectWriteFallback(true);
74-
if (!saveToFile(saveFile)) {
75-
return false;
76-
}
77-
return saveFile.commit();
78-
} else {
79-
qWarning() << "File name too long, disable QSaveFile. path:" << m_filePath;
80-
QFile file(m_filePath);
81-
if (!saveToFile(file)) {
82-
return false;
83-
}
84-
return true;
69+
// QFileInfo fileInfo(m_filePath);
70+
// bool disableSaveProtect = fileInfo.fileName().length() > MAX_FILENAME_LENGTH;
71+
72+
// if (!disableSaveProtect) {
73+
// QSaveFile saveFile(m_filePath);
74+
// saveFile.setDirectWriteFallback(true);
75+
// if (!saveToFile(saveFile)) {
76+
// return false;
77+
// }
78+
// return saveFile.commit();
79+
// } else {
80+
// qWarning() << "File name too long, disable QSaveFile. path:" << m_filePath;
81+
QFile file(m_filePath);
82+
if (!saveToFile(file)) {
83+
return false;
8584
}
85+
return true;
86+
// }
8687
}
8788

8889
/**

0 commit comments

Comments
 (0)