OSDN Git Service

kioslave: try different unrar version argument if "--version" does not work
authorIvailo Monev <xakepa10@gmail.com>
Tue, 3 Aug 2021 17:45:34 +0000 (20:45 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 3 Aug 2021 17:45:34 +0000 (20:45 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
kioslave/thumbnail/comiccreator.cpp
kioslave/thumbnail/comiccreator.h

index 985071c..57b4bfb 100644 (file)
@@ -81,7 +81,7 @@ bool ComicCreator::create(const QString& path, int width, int height, QImage& im
     }
 
     if (cover.isNull()) {
-        kWarning(KIO_THUMB) << "Error creating the comic book thumbnail.";
+        kDebug(KIO_THUMB) << "Error creating the comic book thumbnail.";
         return false;
     }
 
@@ -175,7 +175,10 @@ QImage ComicCreator::extractRARImage(const QString& path)
     /// Extracts the cover image out of the .cbr file.
 
     // Check if unrar is available. Get its path in 'unrarPath'.
-    QString unrar = unrarPath();
+    QString unrar = unrarPath("--version");
+    if (unrar.isEmpty()) {
+        unrar = unrarPath("-v");
+    }
     if (unrar.isEmpty()) {
         kWarning(KIO_THUMB) << "A suitable version of unrar is not available.";
         return QImage();
@@ -217,7 +220,7 @@ QStringList ComicCreator::getRARFileList(const QString& path,
     return entries;
 }
 
-QString ComicCreator::unrarPath() const
+QString ComicCreator::unrarPath(const QString& versionarg) const
 {
     /// Check the standard paths to see if a suitable unrar is available.
     QString unrar = KStandardDirs::findExe("unrar");
@@ -229,7 +232,7 @@ QString ComicCreator::unrarPath() const
     }
     if (!unrar.isEmpty()) {
         QProcess proc;
-        proc.start(unrar, QStringList() << "--version");
+        proc.start(unrar, QStringList() << versionarg);
         proc.waitForFinished(-1);
         const QStringList lines = QString::fromLocal8Bit(proc.readAllStandardOutput()).split
             ('\n', QString::SkipEmptyParts);
index 6777f18..52d14e2 100644 (file)
@@ -67,7 +67,7 @@ class ComicCreator : public QObject, public ThumbCreator
         // For "rar" type files.
         // Uses the non-free 'unrar' executable, if available.
         QImage extractRARImage(const QString& path);
-        QString unrarPath() const;
+        QString unrarPath(const QString& versionarg) const;
         QStringList getRARFileList(const QString& path, const QString& unrarPath);
 
     private slots: