Skip to content

Commit

Permalink
Much faster archive loading
Browse files Browse the repository at this point in the history
  • Loading branch information
tsujan committed Dec 18, 2019
1 parent 8c889f6 commit cfa1f8f
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 108 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
V0.3.2
---------
* Added a workaround for the low performance of QMimeDatabase. Loading of heavy archives is much faster now.

V0.3.1
---------
* Fixed archiving of files from different folders.
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:

25 Oct 2019, V0.3.1
18 Dec 2019, V0.4

See "ChangeLog" for changes.
16 changes: 13 additions & 3 deletions backends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,19 @@ Backend::~Backend() {
}

QString Backend::getMimeType(const QString &fname) {
QMimeDatabase mimeDatabase;
QMimeType mimeType = mimeDatabase.mimeTypeForFile(QFileInfo(fname));
return mimeType.name();
QString mimeType, suffix;
int left = fname.indexOf(QLatin1Char('.'));
if (left != -1) {
suffix = fname.right(fname.size() - left - 1);
mimeType = mimeTypes_.value(suffix);
}
if (mimeType.isEmpty()) {
QMimeDatabase mimeDatabase;
mimeType = mimeDatabase.mimeTypeForFile(QFileInfo(fname)).name();
if (!suffix.isEmpty())
mimeTypes_.insert(suffix, mimeType);
}
return mimeType;
}

void Backend::loadFile(const QString& path, bool withPassword) {
Expand Down
2 changes: 2 additions & 0 deletions backends.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ private slots:

QProcess proc_;

QHash<QString, QString> mimeTypes_; // to speed up mime type search

QString filepath_, tmpfilepath_, arqiverDir_;
QStringList fileArgs_;
/* "keyArgs_" is used, instead of QProcess::arguments(), to exlude file/item names
Expand Down
36 changes: 18 additions & 18 deletions data/translations/arqiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@
<context>
<name>Arqiver::Backend</name>
<message>
<location filename="../../backends.cpp" line="819"/>
<location filename="../../backends.cpp" line="862"/>
<location filename="../../backends.cpp" line="829"/>
<location filename="../../backends.cpp" line="872"/>
<source>Could not read archive</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../backends.cpp" line="822"/>
<location filename="../../backends.cpp" line="867"/>
<location filename="../../backends.cpp" line="832"/>
<location filename="../../backends.cpp" line="877"/>
<source>Archive Loaded</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../backends.cpp" line="829"/>
<location filename="../../backends.cpp" line="915"/>
<location filename="../../backends.cpp" line="839"/>
<location filename="../../backends.cpp" line="925"/>
<source>Modification Finished</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../backends.cpp" line="850"/>
<location filename="../../backends.cpp" line="884"/>
<location filename="../../backends.cpp" line="860"/>
<location filename="../../backends.cpp" line="894"/>
<source>Extraction Finished</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../backends.cpp" line="853"/>
<location filename="../../backends.cpp" line="903"/>
<location filename="../../backends.cpp" line="863"/>
<location filename="../../backends.cpp" line="913"/>
<source>Extraction Failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../backends.cpp" line="996"/>
<location filename="../../backends.cpp" line="1006"/>
<source>%1 is missing from your system.
Please install it for this kind of archive!</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -477,33 +477,33 @@ Do you want to continue?
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1315"/>
<location filename="../../mainWin.cpp" line="1318"/>
<source>A simple Qt archive manager</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1316"/>
<location filename="../../mainWin.cpp" line="1319"/>
<source>based on libarchive, gzip and 7z</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1317"/>
<location filename="../../mainWin.cpp" line="1320"/>
<source>Author</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1318"/>
<location filename="../../mainWin.cpp" line="1321"/>
<source>aka.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1319"/>
<location filename="../../mainWin.cpp" line="1320"/>
<location filename="../../mainWin.cpp" line="1322"/>
<location filename="../../mainWin.cpp" line="1323"/>
<source>About Arqiver</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1319"/>
<location filename="../../mainWin.cpp" line="1322"/>
<source>Translators</source>
<translation type="unfinished"></translation>
</message>
Expand Down
36 changes: 18 additions & 18 deletions data/translations/arqiver_eo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@
<context>
<name>Arqiver::Backend</name>
<message>
<location filename="../../backends.cpp" line="819"/>
<location filename="../../backends.cpp" line="862"/>
<location filename="../../backends.cpp" line="829"/>
<location filename="../../backends.cpp" line="872"/>
<source>Could not read archive</source>
<translation>La arkivo ne legeblis</translation>
</message>
<message>
<location filename="../../backends.cpp" line="822"/>
<location filename="../../backends.cpp" line="867"/>
<location filename="../../backends.cpp" line="832"/>
<location filename="../../backends.cpp" line="877"/>
<source>Archive Loaded</source>
<translation>Arkivo Ŝargita</translation>
</message>
<message>
<location filename="../../backends.cpp" line="829"/>
<location filename="../../backends.cpp" line="915"/>
<location filename="../../backends.cpp" line="839"/>
<location filename="../../backends.cpp" line="925"/>
<source>Modification Finished</source>
<translation>Modifado Farita</translation>
</message>
<message>
<location filename="../../backends.cpp" line="850"/>
<location filename="../../backends.cpp" line="884"/>
<location filename="../../backends.cpp" line="860"/>
<location filename="../../backends.cpp" line="894"/>
<source>Extraction Finished</source>
<translation>Ekstraktado Farita</translation>
</message>
<message>
<location filename="../../backends.cpp" line="853"/>
<location filename="../../backends.cpp" line="903"/>
<location filename="../../backends.cpp" line="863"/>
<location filename="../../backends.cpp" line="913"/>
<source>Extraction Failed</source>
<translation>Ekstraktado Malsukcesis</translation>
</message>
<message>
<location filename="../../backends.cpp" line="996"/>
<location filename="../../backends.cpp" line="1006"/>
<source>%1 is missing from your system.
Please install it for this kind of archive!</source>
<translation>%1 mankas al via sistemo.
Expand Down Expand Up @@ -482,33 +482,33 @@ Do you want to continue?
<translation>Ligilo Al %1</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1315"/>
<location filename="../../mainWin.cpp" line="1318"/>
<source>A simple Qt archive manager</source>
<translation>Simpla Qt-Arkivilo</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1316"/>
<location filename="../../mainWin.cpp" line="1319"/>
<source>based on libarchive, gzip and 7z</source>
<translation>bazita sur libarchive, gzip kaj 7z</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1317"/>
<location filename="../../mainWin.cpp" line="1320"/>
<source>Author</source>
<translation>Verkinto</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1318"/>
<location filename="../../mainWin.cpp" line="1321"/>
<source>aka.</source>
<translation>akk.</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1319"/>
<location filename="../../mainWin.cpp" line="1320"/>
<location filename="../../mainWin.cpp" line="1322"/>
<location filename="../../mainWin.cpp" line="1323"/>
<source>About Arqiver</source>
<translation>Pri Arqiver</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1319"/>
<location filename="../../mainWin.cpp" line="1322"/>
<source>Translators</source>
<translation>Tradukintoj</translation>
</message>
Expand Down
36 changes: 18 additions & 18 deletions data/translations/arqiver_nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@
<context>
<name>Arqiver::Backend</name>
<message>
<location filename="../../backends.cpp" line="819"/>
<location filename="../../backends.cpp" line="862"/>
<location filename="../../backends.cpp" line="829"/>
<location filename="../../backends.cpp" line="872"/>
<source>Could not read archive</source>
<translation>Kan archief niet uitlezen</translation>
</message>
<message>
<location filename="../../backends.cpp" line="822"/>
<location filename="../../backends.cpp" line="867"/>
<location filename="../../backends.cpp" line="832"/>
<location filename="../../backends.cpp" line="877"/>
<source>Archive Loaded</source>
<translation>Archief geladen</translation>
</message>
<message>
<location filename="../../backends.cpp" line="829"/>
<location filename="../../backends.cpp" line="915"/>
<location filename="../../backends.cpp" line="839"/>
<location filename="../../backends.cpp" line="925"/>
<source>Modification Finished</source>
<translation>Bewerking voltooid</translation>
</message>
<message>
<location filename="../../backends.cpp" line="850"/>
<location filename="../../backends.cpp" line="884"/>
<location filename="../../backends.cpp" line="860"/>
<location filename="../../backends.cpp" line="894"/>
<source>Extraction Finished</source>
<translation>Uitpakken voltooid</translation>
</message>
<message>
<location filename="../../backends.cpp" line="853"/>
<location filename="../../backends.cpp" line="903"/>
<location filename="../../backends.cpp" line="863"/>
<location filename="../../backends.cpp" line="913"/>
<source>Extraction Failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../backends.cpp" line="996"/>
<location filename="../../backends.cpp" line="1006"/>
<source>%1 is missing from your system.
Please install it for this kind of archive!</source>
<translation>%1 is niet geïnstalleerd.
Expand Down Expand Up @@ -479,33 +479,33 @@ Do you want to continue?
<translation>Link naar: %1</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1315"/>
<location filename="../../mainWin.cpp" line="1318"/>
<source>A simple Qt archive manager</source>
<translation>Een eenvoudige Qt-archiefbeheerder</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1316"/>
<location filename="../../mainWin.cpp" line="1319"/>
<source>based on libarchive, gzip and 7z</source>
<translation>gebaseerd op libarchive, gzip en 7z</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1317"/>
<location filename="../../mainWin.cpp" line="1320"/>
<source>Author</source>
<translation>Maker</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1318"/>
<location filename="../../mainWin.cpp" line="1321"/>
<source>aka.</source>
<translation>ook bekend als</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1319"/>
<location filename="../../mainWin.cpp" line="1320"/>
<location filename="../../mainWin.cpp" line="1322"/>
<location filename="../../mainWin.cpp" line="1323"/>
<source>About Arqiver</source>
<translation>Over Arqiver</translation>
</message>
<message>
<location filename="../../mainWin.cpp" line="1319"/>
<location filename="../../mainWin.cpp" line="1322"/>
<source>Translators</source>
<translation>Vertalers</translation>
</message>
Expand Down
Loading

0 comments on commit cfa1f8f

Please sign in to comment.