Merge lp:~ken-vandine/content-hub/hardlink_and_fallback_to_copy into lp:content-hub

Proposed by Ken VanDine
Status: Merged
Approved by: Ken VanDine
Approved revision: 140
Merged at revision: 78
Proposed branch: lp:~ken-vandine/content-hub/hardlink_and_fallback_to_copy
Merge into: lp:content-hub
Prerequisite: lp:~ken-vandine/content-hub/quiet_logging
Diff against target: 66 lines (+24/-13)
1 file modified
src/com/ubuntu/content/utils.cpp (+24/-13)
To merge this branch: bzr merge lp:~ken-vandine/content-hub/hardlink_and_fallback_to_copy
Reviewer Review Type Date Requested Status
Michael Sheldon (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+211557@code.launchpad.net

Commit message

If the transfer isn't persistent, attempt to hardlink instead of copying. If
the link fails, fallback to a copy.

Description of the change

If the transfer isn't persistent, attempt to hardlink instead of copying. If
the link fails, fallback to a copy. This should requires an apparmor policy
for content_exchange to deny write access to HubIncoming.

deny @{HOME}/.cache/@{APP_PKGNAME}/HubIncoming/** w,

This policy was added in apparmor-easyprof-ubuntu 1.1.9

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Are there any related MPs required for this MP to build/function as expected?
 * No (besides the prerequisite branch included)
Is your branch in sync with latest trunk
 * Yes
Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
 * Yes
Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/content-hub) on device or emulator?
 * Yes
If you changed the UI, was the change specified/approved by design?
 * No UI changes
If you changed the packaging (debian), did you subscribe a core-dev to this MP?
 * No packaging changes

140. By Ken VanDine

merged trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?

 * Yes, based on https://wiki.ubuntu.com/Process/Merges/TestPlan/content-hub (with updated gallery-app, address-book-app and ubuntu-system-settings branches for new API compatibility)

Did CI run pass? If not, please explain why.

 * Yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?

 * Yes

review: Approve
141. By Ken VanDine

merged

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/com/ubuntu/content/utils.cpp'
2--- src/com/ubuntu/content/utils.cpp 2014-03-20 23:46:04 +0000
3+++ src/com/ubuntu/content/utils.cpp 2014-03-20 23:46:04 +0000
4@@ -29,6 +29,7 @@
5 #include "common.h"
6 #include "debug.h"
7 #include "com/ubuntu/content/type.h"
8+#include <unistd.h>
9
10 namespace cuc = com::ubuntu::content;
11
12@@ -108,6 +109,15 @@
13 return aaProfile;
14 }
15
16+bool is_persistent(QString store)
17+{
18+ TRACE() << Q_FUNC_INFO << store;
19+ QRegExp rx("*.cache/*/HubIncoming/*");
20+ rx.setPatternSyntax(QRegExp::Wildcard);
21+ rx.setCaseSensitivity(Qt::CaseSensitive);
22+ return not rx.exactMatch(store);
23+}
24+
25 QString copy_to_store(const QString& src, const QString& store)
26 {
27 TRACE() << Q_FUNC_INFO;
28@@ -122,24 +132,25 @@
29 st.mkpath(st.absolutePath());
30 QString destFilePath = store + QDir::separator() + fi.fileName();
31 TRACE() << Q_FUNC_INFO << destFilePath;
32- bool result = QFile::copy(fi.filePath(), destFilePath);
33- if (not result)
34- {
35- qWarning() << "Failed to copy to Store:" << store;
36+ bool copy_failed = true;
37+ if (not is_persistent(store))
38+ {
39+ if (link( fi.absoluteFilePath().toStdString().c_str(),
40+ destFilePath.toStdString().c_str() ) < 0)
41+ {
42+ qWarning() << "Can't create hard link to Store:" << store;
43+ } else
44+ copy_failed = false;
45+ }
46+ if (copy_failed)
47+ {
48+ if (not QFile::copy(fi.filePath(), destFilePath))
49+ qWarning() << "Failed to copy to Store:" << store;
50 }
51
52 return QUrl::fromLocalFile(destFilePath).toString();
53 }
54
55-bool is_persistent(QString store)
56-{
57- TRACE() << Q_FUNC_INFO << store;
58- QRegExp rx("*.cache/*/HubIncoming/*");
59- rx.setPatternSyntax(QRegExp::Wildcard);
60- rx.setCaseSensitivity(Qt::CaseSensitive);
61- return not rx.exactMatch(store);
62-}
63-
64 bool purge_store_cache(QString store)
65 {
66 TRACE() << Q_FUNC_INFO << "Store:" << store;

Subscribers

People subscribed via source and target branches