Skip to content

Commit ff8c1b9

Browse files
committed
fix: [unrar] can not extract rar files with longFilenames
prevent extracting RAR files with long filenames when unrar tool is missing Log: as title Bug: https://pms.uniontech.com/bug-view-343139.html
1 parent 748509c commit ff8c1b9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

3rdparty/interface/archiveinterface/cliinterface.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,22 @@ PluginFinishType CliInterface::extractFiles(const QList<FileEntry> &files, const
195195
}
196196
}
197197
}
198+
199+
// 检查是否有可用的 moveProgram 来处理长文件名 (unrar无法修改rar压缩包内文件名)
200+
bool hasMoveCapability = false;
201+
QString moveProgram = m_cliProps->property("moveProgram").toString();
202+
if (!moveProgram.isEmpty()) {
203+
QString moveProgramPath = QStandardPaths::findExecutable(moveProgram);
204+
hasMoveCapability = !moveProgramPath.isEmpty();
205+
}
206+
207+
if (bHandleLongName && !hasMoveCapability) {
208+
qWarning() << "Long filename detected, but moveProgram (" << moveProgram << ") is not available.";
209+
qWarning() << "Archive format:" << m_mimetype.name() << "Skipping long name handling.";
210+
qWarning() << "The extraction tool will report errors for files with names exceeding system limit (255 bytes).";
211+
bHandleLongName = false;
212+
}
213+
198214
if (destPath.startsWith("/tmp") && destPath.contains("/deepin-compressor-")) { // 打开解压列表文件
199215
if (!QDir(destPath).exists()) {
200216
QDir(destPath).mkpath(destPath);
@@ -236,6 +252,7 @@ PluginFinishType CliInterface::extractFiles(const QList<FileEntry> &files, const
236252
} else {
237253
password = options.password;
238254
}
255+
239256
if (!bLnfs) {
240257
for (QMap<QString, FileEntry>::const_iterator iter = arcData.mapFileEntry.begin(); iter != arcData.mapFileEntry.end(); iter++) {
241258
if (NAME_MAX < iter.value().strFileName.toLocal8Bit().length()) {
@@ -244,6 +261,23 @@ PluginFinishType CliInterface::extractFiles(const QList<FileEntry> &files, const
244261
}
245262
}
246263
}
264+
265+
if (bHandleLongName) {
266+
bool hasMoveCapability = false;
267+
QString moveProgram = m_cliProps->property("moveProgram").toString();
268+
if (!moveProgram.isEmpty()) {
269+
QString moveProgramPath = QStandardPaths::findExecutable(moveProgram);
270+
hasMoveCapability = !moveProgramPath.isEmpty();
271+
}
272+
273+
if (!hasMoveCapability) {
274+
qWarning() << "Long filename detected, but moveProgram (" << moveProgram << ") is not available.";
275+
qWarning() << "Archive format:" << m_mimetype.name() << "Skipping long name handling.";
276+
qWarning() << "The extraction tool will report errors for files with names exceeding system limit (255 bytes).";
277+
bHandleLongName = false;
278+
}
279+
}
280+
247281
if (bHandleLongName) {
248282
if (!handleLongNameExtract(arcData.mapFileEntry.values())) {
249283
m_eErrorType = ET_FileWriteError;

0 commit comments

Comments
 (0)