X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=debian%2Fpatches%2Fproper-tempfiles;h=88268c53f424cd535e3b4d2576dcbb999bd948c8;hb=8685c13be479ba6ff194d6998b4346b4d7c4ab7e;hp=bc4d1251a73549be10220872594e62400a6436a4;hpb=2850d99e2d772efc65fa9bc0552d7b6e62dff5c4;p=minitube diff --git a/debian/patches/proper-tempfiles b/debian/patches/proper-tempfiles index bc4d125..88268c5 100644 --- a/debian/patches/proper-tempfiles +++ b/debian/patches/proper-tempfiles @@ -5,30 +5,30 @@ Description: Do proper temporary file creation Author: Jakob Haufe Bug-Debian: http://bugs.debian.org/644935 -diff --git a/src/temporary.cpp b/src/temporary.cpp -index 362cbd8..bebcd1f 100644 ---- a/src/temporary.cpp -+++ b/src/temporary.cpp -@@ -1,7 +1,7 @@ +Index: minitube/src/temporary.cpp +=================================================================== +--- minitube.orig/src/temporary.cpp ++++ minitube/src/temporary.cpp +@@ -21,51 +21,26 @@ $END_LICENSE */ #include "temporary.h" #include "constants.h" --static QList paths; +-static QVector paths; +-#ifdef APP_LINUX +-static QString userName; +-#endif +static QList tempfiles; - #ifdef Q_WS_X11 - static QString userName; - #endif -@@ -10,43 +10,21 @@ Temporary::Temporary() { } - QString Temporary::filename() { + Temporary::Temporary() { } -- static const QString tempDir = QDesktopServices::storageLocation(QDesktopServices::TempLocation); + QString Temporary::filename() { +- static const QString tempDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation); + QTemporaryFile *tempfile = new QTemporaryFile(QDir::tempPath() + "/" + Constants::UNIX_NAME + "-XXXXXX"); ++ tempfiles += tempfile; - QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" + QString::number(qrand()); -+ tempfiles << tempfile; - --#ifdef Q_WS_X11 +- +-#ifdef APP_LINUX - if (userName.isNull()) { - userName = QString(getenv("USERNAME")); - if (userName.isEmpty()) @@ -42,7 +42,8 @@ index 362cbd8..bebcd1f 100644 - - if (QFile::exists(tempFile) && !QFile::remove(tempFile)) { - qDebug() << "Cannot remove temp file" << tempFile; -+ if (tempfiles.size() > 1) { ++ if (tempfiles.size() > 1) ++ { + QTemporaryFile *removedFile = tempfiles.takeFirst(); + delete removedFile; } @@ -63,7 +64,7 @@ index 362cbd8..bebcd1f 100644 } void Temporary::deleteAll() { -- foreach(QString path, paths) { +- foreach(const QString &path, paths) { - if (QFile::exists(path) && !QFile::remove(path)) { - qDebug() << "Cannot remove temp file" << path; - } @@ -71,11 +72,11 @@ index 362cbd8..bebcd1f 100644 + delete tempfile; } } -diff --git a/src/temporary.h b/src/temporary.h -index 50b9633..0453572 100644 ---- a/src/temporary.h -+++ b/src/temporary.h -@@ -3,6 +3,7 @@ +Index: minitube/src/temporary.h +=================================================================== +--- minitube.orig/src/temporary.h ++++ minitube/src/temporary.h +@@ -23,6 +23,7 @@ $END_LICENSE */ #include #include