Merge lp:~osomon/webbrowser-app/create-downloads-folder into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Michael Sheldon
Approved revision: 1501
Merged at revision: 1504
Proposed branch: lp:~osomon/webbrowser-app/create-downloads-folder
Merge into: lp:webbrowser-app
Diff against target: 24 lines (+6/-4)
1 file modified
src/app/webbrowser/downloads-model.cpp (+6/-4)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/create-downloads-folder
Reviewer Review Type Date Requested Status
Michael Sheldon (community) Approve
system-apps-ci-bot continuous-integration Needs Fixing
Review via email: mp+299283@code.launchpad.net

Commit message

Create Downloads folder if it doesn’t exist.

To post a comment you must log in.
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1501
https://jenkins.canonical.com/system-apps/job/lp-webbrowser-app-ci/565/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/856/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/856
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/776
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/776
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/776
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/778/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/778
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/778/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/778
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/778/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/778
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/778/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/778
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/778/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/778
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/778/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/778
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/778/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/778
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/778/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/778
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/778/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-webbrowser-app-ci/565/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Looks good, tested and it works well :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/webbrowser/downloads-model.cpp'
2--- src/app/webbrowser/downloads-model.cpp 2016-01-12 15:01:59 +0000
3+++ src/app/webbrowser/downloads-model.cpp 2016-07-06 09:41:35 +0000
4@@ -288,14 +288,16 @@
5 QString suffix = fi.completeSuffix();
6 QString filename = fi.fileName();
7 QString filenameWithoutSuffix = filename.left(filename.size() - suffix.size());
8- QString dir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
9- QString destination = dir + QDir::separator() + filenameWithoutSuffix + suffix;
10+ QDir dir(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
11+ if (!dir.exists()) {
12+ QDir::root().mkpath(dir.absolutePath());
13+ }
14+ QString destination = dir.absoluteFilePath(filenameWithoutSuffix + suffix);
15 // Avoid filename collision by automatically inserting an incremented
16 // number into the filename if the original name already exists.
17 int append = 1;
18 while (QFile::exists(destination)) {
19- destination = QString("%1%2.%3").arg(dir + QDir::separator() + filenameWithoutSuffix, QString::number(append), suffix);
20- ++append;
21+ destination = dir.absoluteFilePath(QString("%1%2.%3").arg(filenameWithoutSuffix, QString::number(append++), suffix));
22 }
23 if (file.rename(destination)) {
24 setPath(downloadId, destination);

Subscribers

People subscribed via source and target branches

to status/vote changes: