summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/downloadManager.cpp22
-rw-r--r--src/main.cpp3
-rwxr-xr-xsrc/testApp.sh6
3 files changed, 20 insertions, 11 deletions
diff --git a/src/downloadManager.cpp b/src/downloadManager.cpp
index 0262efe..9b44a3d 100644
--- a/src/downloadManager.cpp
+++ b/src/downloadManager.cpp
@@ -74,13 +74,21 @@ void downloadManager::startNextDownload()
tmp.remove(0, tmp.lastIndexOf(QChar('/')) + 1);
if (debug) qDebug() << "Extracted " << tmp << "from " << url.toString();
- outfile.setFileName(downloadPath + "/" + tmp);
- if (!outfile.open(QIODevice::WriteOnly))
- {
+ /* check if filename exists on target file system */
+ QFileInfo fi(downloadPath + "/" + tmp);
+ if (fi.exists()){
+ QString qs = QString(fi.absoluteFilePath() + ".\%1").arg(downloaded);
+ outfile.setFileName(qs);
+ }
+ else
+ outfile.setFileName(downloadPath + "/" + tmp);
+
+ if (!outfile.open(QIODevice::WriteOnly)){
if (debug) qDebug() << "Couldn't open file! Skipping...";
return;
}
-
+ QString qs = QString(fi.absoluteFilePath() + ".\%1").arg(downloaded);
+ qDebug() << "TEST:" << qs;
/* send the request for the file */
QNetworkRequest request(url);
currentDownload = qnam->get(request);
@@ -121,10 +129,12 @@ void downloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal)
QString unit;
if (speed < 1024) {
unit = "bytes/sec";
- } else if (speed < 1024*1024) {
+ }
+ else if (speed < 1024*1024) {
speed /= 1024;
unit = "KB/s";
- } else {
+ }
+ else {
speed /= 1024*1024;
unit = "MB/s";
}
diff --git a/src/main.cpp b/src/main.cpp
index 3138838..689b3e4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -12,7 +12,8 @@ void printHelp()
qout << QObject::tr("Usage: ./fbgui [OPTIONS]") << endl;
qout << QObject::tr("Options:") << endl;
qout << "-u <URL>, --url=<URL> " << QObject::tr("Set which URL to load.") << endl;
- qout << "-d <dir>, --downloaddir=<dir> " << QObject::tr("Specifiy the download directory.") << endl;
+ qout << "-d <dir>, --download=<dir> " << QObject::tr("Specify the download directory.") << endl;
+ qout << "-c <path>, --config=<path> " << QObject::tr("Path to config file.") << endl;
qout << "-D, --debug " << QObject::tr("Activate debug mode.") << endl;
qout << "-h, --help " << QObject::tr("Prints usage information.") << endl;
qout.flush();
diff --git a/src/testApp.sh b/src/testApp.sh
index 4e80f5a..444636b 100755
--- a/src/testApp.sh
+++ b/src/testApp.sh
@@ -3,19 +3,17 @@
# Use: ./testApp.sh [OPTIONS]
# OPTIONS: -D, --debug
# -u <url>, --url=<url>
-# -d <dir>, --downloaddir=<dir> (dir relative)
+# -d <dir>, --download=<dir> absolute dir for downloads.
+# -c <path>, --config=<path> path to config file.
#
script_path="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
-
# to get the path only - not the script name - add
working_path=`dirname "$script_path"`
display_id=$(grep -n $(whoami) /etc/passwd| head -n 1|awk -F : '{print $1}')
-
# Start QT's virtual framebuffer with proper displayID
/usr/local/Trolltech/Qt-4.7.1/bin/qvfb -width 800 -height 600 -qwsdisplay :$display_id &
sleep 0.1
# Start fbgui.
-echo "$working_path/fbgui -display QVFb:$display_id $@"
$working_path/fbgui -display QVFb:$display_id $@
# Check if fbbrowser is not running, if so kill the qvfb.
if [ $(ps aux | grep -v grep | grep -c fbgui) -eq 1 ]