]> git.sur5r.net Git - minitube/blob - debian/patches/proper-tempfiles
Imported Debian patch 1.5-2
[minitube] / debian / patches / proper-tempfiles
1 Description: Do proper temporary file creation
2  Upstream is using predictable temporary file names. Fix this in Debian
3  for now by using QTemporaryFile. This additionally ensures removal of
4  temporary files upon exit.
5 Author: Jakob Haufe <sur5r@sur5r.net>
6 Bug-Debian: http://bugs.debian.org/644935
7
8 --- minitube-1.5.orig/src/MediaView.cpp
9 +++ minitube-1.5/src/MediaView.cpp
10 @@ -127,6 +127,7 @@ MediaView::MediaView(QWidget *parent) :
11      connect(demoTimer, SIGNAL(timeout()), SLOT(demoMessage()));
12  #endif
13  
14 +    tempFile = new QTemporaryFile(this);
15  }
16  
17  void MediaView::initialize() {
18 @@ -346,21 +347,15 @@ void MediaView::gotStreamUrl(QUrl stream
19  
20  
21      QString tempDir = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
22 -#ifdef Q_WS_X11
23 -    QString tempFile = tempDir + "/minitube-" + getenv("USERNAME") + ".mp4";
24 -#else
25 -    QString tempFile = tempDir + "/minitube.mp4";
26 -#endif
27 -    if (QFile::exists(tempFile) && !QFile::remove(tempFile)) {
28 -        qDebug() << "Cannot remove temp file";
29 -    }
30 +    if(tempFile->fileName().isNull())
31 +        tempFile->open();
32  
33      Video *videoCopy = video->clone();
34      if (downloadItem) {
35          downloadItem->stop();
36          delete downloadItem;
37      }
38 -    downloadItem = new DownloadItem(videoCopy, streamUrl, tempFile, this);
39 +    downloadItem = new DownloadItem(videoCopy, streamUrl, tempFile->fileName(), this);
40      connect(downloadItem, SIGNAL(statusChanged()), SLOT(downloadStatusChanged()));
41      // connect(downloadItem, SIGNAL(progress(int)), SLOT(downloadProgress(int)));
42      connect(downloadItem, SIGNAL(bufferProgress(int)), loadingWidget, SLOT(bufferStatus(int)));
43 --- minitube-1.5.orig/src/MediaView.h
44 +++ minitube-1.5/src/MediaView.h
45 @@ -3,6 +3,7 @@
46  
47  #include <QtGui>
48  #include <QtNetwork>
49 +#include <QTemporaryFile>
50  #include <phonon/mediaobject.h>
51  #include <phonon/videowidget.h>
52  #include "View.h"
53 @@ -130,6 +131,8 @@ private:
54      DownloadItem *downloadItem;
55      // QSlider *slider;
56  
57 +    QTemporaryFile *tempFile;
58 +
59  };
60  
61  #endif // __MEDIAVIEW_H__