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
=== modified file 'src/com/ubuntu/content/utils.cpp'
--- src/com/ubuntu/content/utils.cpp 2014-03-20 23:46:04 +0000
+++ src/com/ubuntu/content/utils.cpp 2014-03-20 23:46:04 +0000
@@ -29,6 +29,7 @@
29#include "common.h"29#include "common.h"
30#include "debug.h"30#include "debug.h"
31#include "com/ubuntu/content/type.h"31#include "com/ubuntu/content/type.h"
32#include <unistd.h>
3233
33namespace cuc = com::ubuntu::content;34namespace cuc = com::ubuntu::content;
3435
@@ -108,6 +109,15 @@
108 return aaProfile;109 return aaProfile;
109}110}
110111
112bool is_persistent(QString store)
113{
114 TRACE() << Q_FUNC_INFO << store;
115 QRegExp rx("*.cache/*/HubIncoming/*");
116 rx.setPatternSyntax(QRegExp::Wildcard);
117 rx.setCaseSensitivity(Qt::CaseSensitive);
118 return not rx.exactMatch(store);
119}
120
111QString copy_to_store(const QString& src, const QString& store)121QString copy_to_store(const QString& src, const QString& store)
112{122{
113 TRACE() << Q_FUNC_INFO;123 TRACE() << Q_FUNC_INFO;
@@ -122,24 +132,25 @@
122 st.mkpath(st.absolutePath());132 st.mkpath(st.absolutePath());
123 QString destFilePath = store + QDir::separator() + fi.fileName();133 QString destFilePath = store + QDir::separator() + fi.fileName();
124 TRACE() << Q_FUNC_INFO << destFilePath;134 TRACE() << Q_FUNC_INFO << destFilePath;
125 bool result = QFile::copy(fi.filePath(), destFilePath);135 bool copy_failed = true;
126 if (not result)136 if (not is_persistent(store))
127 {137 {
128 qWarning() << "Failed to copy to Store:" << store;138 if (link( fi.absoluteFilePath().toStdString().c_str(),
139 destFilePath.toStdString().c_str() ) < 0)
140 {
141 qWarning() << "Can't create hard link to Store:" << store;
142 } else
143 copy_failed = false;
144 }
145 if (copy_failed)
146 {
147 if (not QFile::copy(fi.filePath(), destFilePath))
148 qWarning() << "Failed to copy to Store:" << store;
129 }149 }
130150
131 return QUrl::fromLocalFile(destFilePath).toString();151 return QUrl::fromLocalFile(destFilePath).toString();
132}152}
133153
134bool is_persistent(QString store)
135{
136 TRACE() << Q_FUNC_INFO << store;
137 QRegExp rx("*.cache/*/HubIncoming/*");
138 rx.setPatternSyntax(QRegExp::Wildcard);
139 rx.setCaseSensitivity(Qt::CaseSensitive);
140 return not rx.exactMatch(store);
141}
142
143bool purge_store_cache(QString store)154bool purge_store_cache(QString store)
144{155{
145 TRACE() << Q_FUNC_INFO << "Store:" << store;156 TRACE() << Q_FUNC_INFO << "Store:" << store;

Subscribers

People subscribed via source and target branches