Skip to content

Commit

Permalink
Fixed an issue in file removal with 7z archives
Browse files Browse the repository at this point in the history
It was probably caused by a problem in 7z.

Also, don't update the tree unnecessarily.
  • Loading branch information
tsujan committed Mar 8, 2019
1 parent 3a8d7fc commit 9885a0d
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 143 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ V0.2.0
* With tar/bsdtar and if the parent dir exists, change the parent dir name instead of extracting in a child dir.
* A root archive file may mean a parent directory or a single file. Previously, it was supposed to be a parent directory and that caused single files not to be extracted with non-Gzip archives when they were present in the extraction directory.
* If a file comes after its containing folder in the command line, bsdtar doesn't extract the folder. A workaround is added for this behavior.
* Prevent tree collapse after extracting an rpm archive.
* Don't update the tree unnecessarily.
* Fixed a bug in removal of encrypted files inside 7z archives.

V0.1.0
---------
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Latest version:

7 Mar 2019, V0.2.0
8 Mar 2019, V0.2.0

See "ChangeLog" for changes.
46 changes: 23 additions & 23 deletions backends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
namespace Arqiver {

Backend::Backend(QObject *parent) : QObject(parent) {
PROC.setProcessChannelMode(QProcess::MergedChannels);
connect(&PROC, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &Backend::procFinished);
connect(&PROC, &QProcess::readyReadStandardOutput, this, &Backend::processData);
connect(&PROC, &QProcess::started, this, &Backend::processStarting);
connect(&PROC, &QProcess::errorOccurred, this, &Backend::onError);
proc_.setProcessChannelMode(QProcess::MergedChannels);
connect(&proc_, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &Backend::procFinished);
connect(&proc_, &QProcess::readyReadStandardOutput, this, &Backend::processData);
connect(&proc_, &QProcess::started, this, &Backend::processStarting);
connect(&proc_, &QProcess::errorOccurred, this, &Backend::onError);
LIST = false;
isGzip_ = is7z_ = false;
starting7z_ = encryptionQueried_ = encrypted_ = encryptedList_ = false;
Expand Down Expand Up @@ -138,7 +138,7 @@ QString Backend::currentFile() {
}

bool Backend::isWorking(){
return (PROC.state() != QProcess::Running);
return (proc_.state() != QProcess::Running);
}

QStringList Backend::hierarchy() {
Expand Down Expand Up @@ -246,7 +246,7 @@ void Backend::startAdd(QStringList& paths, bool absolutePaths) {
args << "a" << fileArgs_ << paths;
starting7z_ = true;
keyArgs_ << "a";
PROC.start ("7z", args);
proc_.start ("7z", args);
return;
}
/* NOTE: All paths should have the same parent directory.
Expand Down Expand Up @@ -280,7 +280,7 @@ void Backend::startAdd(QStringList& paths, bool absolutePaths) {
args << "@" + filepath_;
}
keyArgs_ << "-c" << "-a" << "-C";
PROC.start(TAR_CMD, args);
proc_.start(TAR_CMD, args);
}

void Backend::startRemove(QStringList& paths) {
Expand All @@ -293,12 +293,12 @@ void Backend::startRemove(QStringList& paths) {
paths.removeDuplicates();
QStringList args;
if (is7z_) {
if (encryptedList_)
args << "-p" + pswrd_; // we had the password to open the archive
if (encrypted_)
args << "-p" + pswrd_;
args << "d" << fileArgs_ << paths;
starting7z_ = true;
keyArgs_ << "d";
PROC.start("7z", args);
proc_.start("7z", args);
return;
}
args << "-c" << "-a";
Expand All @@ -310,7 +310,7 @@ void Backend::startRemove(QStringList& paths) {
}
args << "@" + filepath_;
keyArgs_ << "-c" << "-a" << "--exclude";
PROC.start(TAR_CMD, args);
proc_.start(TAR_CMD, args);
}

void Backend::startExtract(const QString& path, const QString& file, bool overwrite, bool preservePaths) {
Expand All @@ -323,7 +323,7 @@ void Backend::startExtract(const QString& path, const QStringList& files, bool o
/* if the extraction takes place in the same directory, we could do it
in the usual way but the standard output method works in all cases */
/*if (0 && path == filepath_.section("/", 0, -2)) {
PROC.start("gzip", QStringList() << "-d" << "-k" << filepath_);
proc_.start("gzip", QStringList() << "-d" << "-k" << filepath_);
return;
}*/
emit processStarting();
Expand Down Expand Up @@ -429,14 +429,14 @@ void Backend::startExtract(const QString& path, const QStringList& files, bool o

if(is7z_) {
args << "-o" + xPath;
PROC.start("7z", args);
proc_.start("7z", args);
}
else {
args << "-C" << xPath;
if (archiveRootExists && contents_.size() > 1)
args << "--strip-components" << "1"; // the parent name is changed
keyArgs_ << "-C";
PROC.start(TAR_CMD, args); // doesn't create xPath if not existing
proc_.start(TAR_CMD, args); // doesn't create xPath if not existing
}
}

Expand Down Expand Up @@ -703,7 +703,7 @@ void Backend::startList(bool withPassword) {
LIST = true;
if (isGzip_) {
keyArgs_ << "-l";
PROC.start("gzip", QStringList() << "-l" << filepath_);
proc_.start("gzip", QStringList() << "-l" << filepath_);
}
else if (is7z_) {
QStringList args;
Expand All @@ -713,13 +713,13 @@ void Backend::startList(bool withPassword) {
args << "l";
starting7z_ = true;
keyArgs_ << "l";
PROC.start("7z", QStringList() << args << fileArgs_);
proc_.start("7z", QStringList() << args << fileArgs_);
}
else {
QStringList args;
args << "-tv";
keyArgs_ << "-tv";
PROC.start(TAR_CMD, QStringList() << args << fileArgs_);
proc_.start(TAR_CMD, QStringList() << args << fileArgs_);
}
}

Expand All @@ -736,7 +736,7 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus) {
args << "l";
starting7z_ = true;
keyArgs_.clear(); keyArgs_ << "l";
PROC.start("7z", QStringList() << args << fileArgs_);
proc_.start("7z", QStringList() << args << fileArgs_);
}
return;
}
Expand Down Expand Up @@ -773,7 +773,7 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus) {
}
else { // extraction
/*if (retcode == 0) {
QStringList args = PROC.arguments();
QStringList args = proc_.arguments();
for (int i = 0; i < args.length(); i++) {
if(args[i].startsWith("-o")) //just extracted to a dir - open it now
QProcess::startDetached("xdg-open \"" + args[i].section("-o", 1, -1) + "\"");
Expand Down Expand Up @@ -861,7 +861,7 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus) {
void Backend::processData() {
if (is7z_ && !encryptionQueried_) {
if (!encryptedList_) {
QString read = PROC.readAllStandardOutput();
QString read = proc_.readAllStandardOutput();
if (read.contains("\nERROR: ")) { // ERROR: FILE_PATH : Can not open encrypted archive. Wrong password?
encryptedList_ = encrypted_ = true;
}
Expand All @@ -888,7 +888,7 @@ void Backend::processData() {
return; // no listing here
}
static QString data;
QString read = data + PROC.readAllStandardOutput();
QString read = data + proc_.readAllStandardOutput();
if (read.endsWith("\n"))
data.clear();
else {
Expand Down Expand Up @@ -923,7 +923,7 @@ void Backend::processData() {
void Backend::onError(QProcess::ProcessError error) {
if (error == QProcess::FailedToStart)
emit errorMsg(tr("%1 is missing from your system.\nPlease install it for this kind of archive!")
.arg(PROC.program()));
.arg(proc_.program()));
}

}
2 changes: 1 addition & 1 deletion backends.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private slots:
private:
void parseLines(QStringList& lines);

QProcess PROC;
QProcess proc_;

QString filepath_, tmpfilepath_, arqiverDir_;
QStringList fileArgs_;
Expand Down
54 changes: 27 additions & 27 deletions data/translations/arqiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ Please install it for this kind of archive!</source>
</message>
<message>
<location filename="../../mainWin.cpp" line="467"/>
<location filename="../../mainWin.cpp" line="782"/>
<location filename="../../mainWin.cpp" line="807"/>
<source>Question</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -387,102 +387,102 @@ Please install it for this kind of archive!</source>
<message>
<location filename="../../mainWin.cpp" line="566"/>
<location filename="../../mainWin.cpp" line="581"/>
<location filename="../../mainWin.cpp" line="741"/>
<location filename="../../mainWin.cpp" line="747"/>
<location filename="../../mainWin.cpp" line="766"/>
<location filename="../../mainWin.cpp" line="772"/>
<source>Adding Items...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="592"/>
<location filename="../../mainWin.cpp" line="615"/>
<source>Removing Items...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="604"/>
<location filename="../../mainWin.cpp" line="709"/>
<location filename="../../mainWin.cpp" line="719"/>
<location filename="../../mainWin.cpp" line="792"/>
<location filename="../../mainWin.cpp" line="804"/>
<location filename="../../mainWin.cpp" line="627"/>
<location filename="../../mainWin.cpp" line="733"/>
<location filename="../../mainWin.cpp" line="744"/>
<location filename="../../mainWin.cpp" line="818"/>
<location filename="../../mainWin.cpp" line="830"/>
<source>Extracting...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="618"/>
<location filename="../../mainWin.cpp" line="641"/>
<source>View Current Item</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="629"/>
<location filename="../../mainWin.cpp" line="637"/>
<location filename="../../mainWin.cpp" line="652"/>
<location filename="../../mainWin.cpp" line="660"/>
<source>Enter Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="641"/>
<location filename="../../mainWin.cpp" line="664"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="642"/>
<location filename="../../mainWin.cpp" line="665"/>
<source>OK</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="646"/>
<location filename="../../mainWin.cpp" line="669"/>
<source>Encrypt the file list</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="647"/>
<location filename="../../mainWin.cpp" line="670"/>
<source>This will take effect after files/folders are added.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="706"/>
<location filename="../../mainWin.cpp" line="773"/>
<location filename="../../mainWin.cpp" line="729"/>
<location filename="../../mainWin.cpp" line="798"/>
<source>Extract Into Directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="783"/>
<location filename="../../mainWin.cpp" line="808"/>
<source>Some files will be overwritten.
Do you want to continue?
</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="896"/>
<location filename="../../mainWin.cpp" line="922"/>
<source>Link To: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1132"/>
<location filename="../../mainWin.cpp" line="1158"/>
<source>A simple Qt archive manager</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1133"/>
<location filename="../../mainWin.cpp" line="1159"/>
<source>based on libarchive, gzip and 7z</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1134"/>
<location filename="../../mainWin.cpp" line="1160"/>
<source>Author</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1135"/>
<location filename="../../mainWin.cpp" line="1161"/>
<source>aka.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1136"/>
<location filename="../../mainWin.cpp" line="1137"/>
<location filename="../../mainWin.cpp" line="1162"/>
<location filename="../../mainWin.cpp" line="1163"/>
<source>About Arqiver</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1136"/>
<location filename="../../mainWin.cpp" line="1162"/>
<source>Translators</source>
<translation type="unfinished"></translation>
</message>
Expand Down
Loading

0 comments on commit 9885a0d

Please sign in to comment.