X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=debian%2Fpatches%2Fproper-tempfiles;h=2f5d44d112f9e33bb3cb2fd30bbc71ceac647833;hb=6efb1335adebaf59c8af9ec92c37099380f43fb0;hp=bc4d1251a73549be10220872594e62400a6436a4;hpb=8fd32edb7d4196ea411865652e30652c3bc99a43;p=minitube diff --git a/debian/patches/proper-tempfiles b/debian/patches/proper-tempfiles index bc4d125..2f5d44d 100644 --- a/debian/patches/proper-tempfiles +++ b/debian/patches/proper-tempfiles @@ -6,29 +6,30 @@ Author: Jakob Haufe Bug-Debian: http://bugs.debian.org/644935 diff --git a/src/temporary.cpp b/src/temporary.cpp -index 362cbd8..bebcd1f 100644 +index 2bf7fcd..0561ecb 100644 --- a/src/temporary.cpp +++ b/src/temporary.cpp -@@ -1,7 +1,7 @@ +@@ -21,52 +21,27 @@ $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() { -- static const QString tempDir = QDesktopServices::storageLocation(QDesktopServices::TempLocation); -+ QTemporaryFile *tempfile = new QTemporaryFile(QDir::tempPath() + "/" + Constants::UNIX_NAME + "-XXXXXX"); + Temporary::Temporary() { } -- QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" + QString::number(qrand()); -+ tempfiles << tempfile; + QString Temporary::filename() { +- static const QString tempDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation); ++ QTemporaryFile *tempfile = new QTemporaryFile(QDir::tempPath() + "/" + QString::number(qrand())); ++ tempfiles += tempfile; --#ifdef Q_WS_X11 +- QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" + +- QString::number(QRandomGenerator::global()->generate()); +- +-#ifdef APP_LINUX - if (userName.isNull()) { - userName = QString(getenv("USERNAME")); - if (userName.isEmpty()) @@ -42,11 +43,8 @@ index 362cbd8..bebcd1f 100644 - - 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) { @@ -54,16 +52,20 @@ index 362cbd8..bebcd1f 100644 - 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() { -- foreach(QString path, paths) { +- foreach(const QString &path, paths) { - if (QFile::exists(path) && !QFile::remove(path)) { - qDebug() << "Cannot remove temp file" << path; - } @@ -72,10 +74,10 @@ index 362cbd8..bebcd1f 100644 } } diff --git a/src/temporary.h b/src/temporary.h -index 50b9633..0453572 100644 +index de5e24d..b8fbba9 100644 --- a/src/temporary.h +++ b/src/temporary.h -@@ -3,6 +3,7 @@ +@@ -23,6 +23,7 @@ $END_LICENSE */ #include #include