]> git.sur5r.net Git - minitube/commitdiff
Refresh proper-tempfiles
authorJakob Haufe <sur5r@debian.org>
Sun, 31 May 2020 16:15:04 +0000 (16:15 +0000)
committerJakob Haufe <sur5r@debian.org>
Sun, 31 May 2020 16:15:04 +0000 (16:15 +0000)
debian/patches/proper-tempfiles

index 88268c53f424cd535e3b4d2576dcbb999bd948c8..2f5d44d112f9e33bb3cb2fd30bbc71ceac647833 100644 (file)
@@ -5,11 +5,11 @@ Description: Do proper temporary file creation
 Author: Jakob Haufe <sur5r@sur5r.net>
 Bug-Debian: http://bugs.debian.org/644935
 
-Index: minitube/src/temporary.cpp
-===================================================================
---- minitube.orig/src/temporary.cpp
-+++ minitube/src/temporary.cpp
-@@ -21,51 +21,26 @@ $END_LICENSE */
+diff --git a/src/temporary.cpp b/src/temporary.cpp
+index 2bf7fcd..0561ecb 100644
+--- a/src/temporary.cpp
++++ b/src/temporary.cpp
+@@ -21,52 +21,27 @@ $END_LICENSE */
  #include "temporary.h"
  #include "constants.h"
  
@@ -23,10 +23,11 @@ Index: minitube/src/temporary.cpp
  
  QString Temporary::filename() {
 -    static const QString tempDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
-+    QTemporaryFile *tempfile = new QTemporaryFile(QDir::tempPath() + "/" + Constants::UNIX_NAME + "-XXXXXX");
++    QTemporaryFile *tempfile = new QTemporaryFile(QDir::tempPath() + "/" + QString::number(qrand()));
 +    tempfiles += tempfile;
  
--    QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" + QString::number(qrand());
+-    QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" +
+-                       QString::number(QRandomGenerator::global()->generate());
 -
 -#ifdef APP_LINUX
 -    if (userName.isNull()) {
@@ -42,12 +43,8 @@ Index: minitube/src/temporary.cpp
 -
 -    if (QFile::exists(tempFile) && !QFile::remove(tempFile)) {
 -        qDebug() << "Cannot remove temp file" << tempFile;
-+    if (tempfiles.size() > 1)
-+    {
-+        QTemporaryFile *removedFile = tempfiles.takeFirst();
-+        delete removedFile;
-     }
+-    }
+-
 -    paths << tempFile;
 -
 -    if (paths.size() > 1) {
@@ -55,12 +52,16 @@ Index: minitube/src/temporary.cpp
 -        if (QFile::exists(removedFile) && !QFile::remove(removedFile)) {
 -            qDebug() << "Cannot remove temp file" << removedFile;
 -        }
--    }
--
++    if(tempfiles.size() > 1)
++    {
++        QTemporaryFile *removedFile = tempfiles.takeFirst();
++        delete removedFile;
+     }
 -    return tempFile;
--
 +    tempfile->open();
 +    return tempfile->fileName();
  }
  
  void Temporary::deleteAll() {
@@ -72,10 +73,10 @@ Index: minitube/src/temporary.cpp
 +        delete tempfile;
      }
  }
-Index: minitube/src/temporary.h
-===================================================================
---- minitube.orig/src/temporary.h
-+++ minitube/src/temporary.h
+diff --git a/src/temporary.h b/src/temporary.h
+index de5e24d..b8fbba9 100644
+--- a/src/temporary.h
++++ b/src/temporary.h
 @@ -23,6 +23,7 @@ $END_LICENSE */
  
  #include <QtCore>