Skip to content

Commit 849c3d3

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 849c3d3

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

3rdparty/interface/archiveinterface/cliinterface.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ PluginFinishType CliInterface::extractFiles(const QList<FileEntry> &files, const
195195
}
196196
}
197197
}
198+
199+
if (bHandleLongName && !checkMoveCapability()) {
200+
qWarning() << "Long filename detected, but moveProgram (" << m_cliProps->property("moveProgram").toString() << ") is not available.";
201+
qWarning() << "Archive format:" << m_mimetype.name() << "Skipping long name handling.";
202+
qWarning() << "The extraction tool will report errors for files with names exceeding system limit (255 bytes).";
203+
bHandleLongName = false;
204+
}
205+
198206
if (destPath.startsWith("/tmp") && destPath.contains("/deepin-compressor-")) { // 打开解压列表文件
199207
if (!QDir(destPath).exists()) {
200208
QDir(destPath).mkpath(destPath);
@@ -236,6 +244,7 @@ PluginFinishType CliInterface::extractFiles(const QList<FileEntry> &files, const
236244
} else {
237245
password = options.password;
238246
}
247+
239248
if (!bLnfs) {
240249
for (QMap<QString, FileEntry>::const_iterator iter = arcData.mapFileEntry.begin(); iter != arcData.mapFileEntry.end(); iter++) {
241250
if (NAME_MAX < iter.value().strFileName.toLocal8Bit().length()) {
@@ -244,6 +253,14 @@ PluginFinishType CliInterface::extractFiles(const QList<FileEntry> &files, const
244253
}
245254
}
246255
}
256+
257+
if (bHandleLongName && !checkMoveCapability()) {
258+
qWarning() << "Long filename detected, but moveProgram (" << m_cliProps->property("moveProgram").toString() << ") is not available.";
259+
qWarning() << "Archive format:" << m_mimetype.name() << "Skipping long name handling.";
260+
qWarning() << "The extraction tool will report errors for files with names exceeding system limit (255 bytes).";
261+
bHandleLongName = false;
262+
}
263+
247264
if (bHandleLongName) {
248265
if (!handleLongNameExtract(arcData.mapFileEntry.values())) {
249266
m_eErrorType = ET_FileWriteError;
@@ -1098,6 +1115,17 @@ bool CliInterface::moveExtractTempFilesToDest(const QList<FileEntry> &files, con
10981115
return moveSuccess;
10991116
}
11001117

1118+
bool CliInterface::checkMoveCapability()
1119+
{
1120+
bool hasMoveCapability = false;
1121+
QString moveProgram = m_cliProps->property("moveProgram").toString();
1122+
if (!moveProgram.isEmpty()) {
1123+
QString moveProgramPath = QStandardPaths::findExecutable(moveProgram);
1124+
hasMoveCapability = !moveProgramPath.isEmpty();
1125+
}
1126+
return hasMoveCapability;
1127+
}
1128+
11011129
void CliInterface::removeExtractedFilesOnFailure(const QString &strTargetPath, const QList<FileEntry> &entries)
11021130
{
11031131
QList<FileEntry> listToRemove = entries;

3rdparty/interface/archiveinterface/cliinterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ class CliInterface : public ReadWriteArchiveInterface
202202

203203
bool handleLongNameExtract(const QList<FileEntry> &files);
204204

205+
bool checkMoveCapability();
206+
205207
private slots:
206208
/**
207209
* @brief readStdout 读取命令行输出

0 commit comments

Comments
 (0)