Merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-13 into lp:ubuntu-filemanager-app

Proposed by Carlos Jose Mazieri on 2015-07-21
Status: Merged
Approved by: Arto Jalkanen on 2015-08-09
Approved revision: 445
Merged at revision: 451
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-13
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-12
Diff against target: 244 lines (+49/-37)
3 files modified
src/plugin/folderlistmodel/CMakeLists.txt (+2/-0)
src/plugin/folderlistmodel/filesystemaction.cpp (+40/-30)
src/plugin/folderlistmodel/filesystemaction.h (+7/-7)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-13
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration 2015-07-21 Approve on 2015-08-22
Arto Jalkanen 2015-07-21 Approve on 2015-08-09
Review via email: mp+265390@code.launchpad.net

This proposal supersedes a proposal from 2015-07-19.

Commit message

Some DirItemInfo objects created by targetLocation in Actions
QFile is no longer used in Actions, instead the abstract LocationItemFile is created by the suitable Location object

Description of the change

All QFile usage replaced by LocationItemFile.

* MP resubmitted to force a new build.

To post a comment you must log in.
445. By Carlos Jose Mazieri on 2015-07-21

Fixed CMakeLists.txt

Arto Jalkanen (ajalkane) :
review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/folderlistmodel/CMakeLists.txt'
2--- src/plugin/folderlistmodel/CMakeLists.txt 2015-07-21 22:53:31 +0000
3+++ src/plugin/folderlistmodel/CMakeLists.txt 2015-07-21 22:53:31 +0000
4@@ -45,6 +45,8 @@
5 locationurl.h
6 locationitemdiriterator.cpp
7 locationitemdiriterator.h
8+ locationitemfile.cpp
9+ locationitemfile.h
10 cleanurl.cpp
11 cleanurl.h
12 urliteminfo.cpp
13
14=== modified file 'src/plugin/folderlistmodel/filesystemaction.cpp'
15--- src/plugin/folderlistmodel/filesystemaction.cpp 2015-07-21 22:53:31 +0000
16+++ src/plugin/folderlistmodel/filesystemaction.cpp 2015-07-21 22:53:31 +0000
17@@ -40,7 +40,7 @@
18 #include "location.h"
19 #include "locationsfactory.h"
20 #include "locationitemdiriterator.h"
21-
22+#include "locationitemfile.h"
23
24 #if defined(Q_OS_UNIX)
25 #include <sys/statvfs.h>
26@@ -669,7 +669,9 @@
27 }
28 else
29 {
30- m_cancelCurrentAction = !QFile::remove(fi.absoluteFilePath());
31+ LocationItemFile *qFile = m_curAction->sourceLocation->newFile(fi.absoluteFilePath());
32+ m_cancelCurrentAction = !qFile->remove();
33+ delete qFile;
34 }
35 #if DEBUG_REMOVE
36 qDebug() << Q_FUNC_INFO << "remove ret=" << !m_cancelCurrentAction << fi.absoluteFilePath();
37@@ -743,14 +745,17 @@
38 const DirItemInfo &fi = entry->reversedOrder.at(entry->currItem);
39 QString orig = fi.absoluteFilePath();
40 QString target = targetFrom(orig, entry);
41+#if DEBUG_MESSAGES
42+ qDebug() << "orig:" << orig << "target:" << target;
43+#endif
44 QString path(target);
45 // do this here to allow progress send right item number, copySingleFile will emit progress()
46 m_curAction->currItem++;
47 //--
48 if (fi.isFile() || fi.isSymLink())
49 {
50- DirItemInfo t(target);
51- path = t.path();
52+ QScopedPointer <DirItemInfo> t(m_curAction->targetLocation->newItemInfo(target));
53+ path = t->path();
54 }
55 //check if the main item in the entry is a directory
56 //if so it needs to appear on any attached view
57@@ -763,7 +768,7 @@
58 QDir entryDirObj(entryDir);
59 if (!entryDirObj.exists() && entryDirObj.mkpath(entryDir))
60 {
61- QScopedPointer <DirItemInfo> item(m_locationsFactory->currentLocation()->newItemInfo(entryDir));
62+ QScopedPointer <DirItemInfo> item(m_curAction->targetLocation->newItemInfo(entryDir));
63 entry->added = true;
64 notifyActionOnItem(*item, ItemAdded);
65 }
66@@ -789,8 +794,10 @@
67 else
68 if (fi.isDir())
69 {
70+ LocationItemFile *qFile = m_curAction->targetLocation->newFile(target);
71 m_cancelCurrentAction = !
72- QFile(target).setPermissions(fi.permissions());
73+ qFile->setPermissions(fi.permissions());
74+ delete qFile;
75 if (m_cancelCurrentAction)
76 {
77 m_errorTitle = QObject::tr("Could not set permissions to dir");
78@@ -803,7 +810,7 @@
79 {
80 qint64 needsSize = 0;
81 m_curAction->copyFile.clear();
82- m_curAction->copyFile.source = new QFile(orig);
83+ m_curAction->copyFile.source = m_curAction->sourceLocation->newFile(orig);
84 m_cancelCurrentAction = !m_curAction->copyFile.source->open(QFile::ReadOnly);
85 if (m_cancelCurrentAction)
86 {
87@@ -814,7 +821,7 @@
88 {
89 needsSize = m_curAction->copyFile.source->size();
90 //create destination
91- m_curAction->copyFile.target = new QFile(target);
92+ m_curAction->copyFile.target = m_curAction->targetLocation->newFile(target);
93 m_curAction->copyFile.targetName = target;
94 //first open it read-only to get its size if exists
95 if (m_curAction->copyFile.target->open(QFile::ReadOnly))
96@@ -823,7 +830,7 @@
97 m_curAction->copyFile.target->close();
98 }
99 //check if there is disk space to copy source to target
100- if (needsSize > 0 && !m_locationsFactory->currentLocation()->isThereDiskSpace(entry->itemPaths.targetPath(), needsSize))
101+ if (needsSize > 0 && !m_curAction->targetLocation->isThereDiskSpace(entry->itemPaths.targetPath(), needsSize))
102 {
103 m_cancelCurrentAction = true;
104 m_errorTitle = QObject::tr("There is no space to copy");
105@@ -848,7 +855,7 @@
106 //depending on the file size it may take longer, the view needs to be informed
107 if (m_curAction->copyFile.isEntryItem && !m_cancelCurrentAction)
108 {
109- QScopedPointer <DirItemInfo> item(m_locationsFactory->currentLocation()->newItemInfo(target));
110+ QScopedPointer <DirItemInfo> item(m_curAction->targetLocation->newItemInfo(target));
111 if (!entry->alreadyExists)
112 {
113 entry->added = true;
114@@ -877,9 +884,7 @@
115 * \param entry
116 */
117 void FileSystemAction::moveEntry(ActionEntry *entry)
118-{
119- QFile file;
120-
121+{
122 for(; !m_cancelCurrentAction &&
123 entry->currStep < STEP_FILES &&
124 m_curAction->currItem < m_curAction->totalItems &&
125@@ -889,36 +894,38 @@
126
127 {
128 const DirItemInfo &fi = entry->reversedOrder.at(entry->currItem);
129- file.setFileName(fi.absoluteFilePath());
130- DirItemInfo targetInfo(entry->itemPaths.target());
131+ QScopedPointer<LocationItemFile> file(m_curAction->sourceLocation->newFile(fi.absoluteFilePath()));
132+ QScopedPointer<DirItemInfo> targetInfo(m_curAction->targetLocation->newItemInfo(entry->itemPaths.target()));
133 //rename will fail
134- if (targetInfo.exists())
135+ if (targetInfo->exists())
136 {
137 //will not emit removed() neither added()
138 entry->added = true;
139- if (targetInfo.isFile() || targetInfo.isSymLink())
140+ if (targetInfo->isFile() || targetInfo->isSymLink())
141 {
142- if (!QFile::remove(targetInfo.absoluteFilePath()))
143+ QScopedPointer<LocationItemFile>
144+ targetFile(m_curAction->sourceLocation->newFile(targetInfo->absoluteFilePath()));
145+ if (!targetFile->remove())
146 {
147 m_cancelCurrentAction = true;
148 m_errorTitle = QObject::tr("Could not remove the directory/file ") +
149- targetInfo.absoluteFilePath();
150+ targetInfo->absoluteFilePath();
151 m_errorMsg = ::strerror(errno);
152 }
153 }
154- else
155- if (targetInfo.isDir())
156+ else //only for local disk operations
157+ if (targetInfo->isDir() && !m_curAction->isRemote())
158 {
159 //move target to /tmp and remove it later by creating an Remove action
160 //this will emit removed()
161- moveDirToTempAndRemoveItLater(targetInfo.absoluteFilePath());
162+ moveDirToTempAndRemoveItLater(targetInfo->absoluteFilePath());
163 }
164 }
165- if (!m_cancelCurrentAction && !file.rename(entry->itemPaths.target()))
166+ if (!m_cancelCurrentAction && !file->rename(entry->itemPaths.target()))
167 {
168 m_cancelCurrentAction = true;
169 m_errorTitle = QObject::tr("Could not move the directory/file ") +
170- targetInfo.absoluteFilePath();
171+ targetInfo->absoluteFilePath();
172 m_errorMsg = ::strerror(errno);
173 }
174 }//for
175@@ -1386,7 +1393,10 @@
176 #if defined(DEBUG_MESSAGES) || defined(REGRESSION_TEST_FOLDERLISTMODEL)
177 qDebug() << Q_FUNC_INFO << dir << "being moved to" << tempDir;
178 #endif
179- if (QFile::rename(dir, tempDir))
180+ LocationItemFile *qFile = m_curAction->targetLocation->newFile(dir);
181+ bool removed = qFile->rename(tempDir);
182+ delete qFile;
183+ if (removed)
184 {
185 if (m_curAction->auxAction == 0)
186 { // this new action as Remove will remove all dirs
187@@ -1424,7 +1434,7 @@
188 {
189 const DirItemInfo& fi =
190 entry->reversedOrder.at(entry->reversedOrder.count() -1);
191- DirItemInfo backuped;
192+ QScopedPointer<DirItemInfo> backuped(m_curAction->targetLocation->newItemInfo(QLatin1String(0)));
193 int counter=0;
194 QString name;
195 do
196@@ -1447,12 +1457,12 @@
197 }
198 }
199 name.insert(pos,copy);
200- backuped.setFile(fi.absolutePath(), name);
201- } while (backuped.exists() && counter < 100);
202+ backuped->setFile(fi.absolutePath(), name);
203+ } while (backuped->exists() && counter < 100);
204 if (counter < 100)
205 {
206- entry->newName = new QString(backuped.fileName());
207- entry->itemPaths.setTargetFullName( backuped.absoluteFilePath() );
208+ entry->newName = new QString(backuped->fileName());
209+ entry->itemPaths.setTargetFullName( backuped->absoluteFilePath() );
210 ret = true;
211 }
212 }
213
214=== modified file 'src/plugin/folderlistmodel/filesystemaction.h'
215--- src/plugin/folderlistmodel/filesystemaction.h 2015-07-21 22:53:31 +0000
216+++ src/plugin/folderlistmodel/filesystemaction.h 2015-07-21 22:53:31 +0000
217@@ -49,7 +49,7 @@
218 #define AMOUNT_COPIED_TO_REFRESH_ITEM_INFO 50000000
219
220 class DirModelMimeData;
221-class QFile;
222+class LocationItemFile;
223 class QTemporaryFile;
224 class Location;
225 class LocationsFactory;
226@@ -157,12 +157,12 @@
227 CopyFile();
228 ~CopyFile();
229 void clear();
230- qint64 bytesWritten; // set 0 when reach bytesToNotify, notify progress
231- QFile * source;
232- QFile * target;
233- QString targetName;
234- bool isEntryItem; //true when the file being copied is at toplevel of the copy/cut operation
235- qint64 amountSavedToRefresh;
236+ qint64 bytesWritten; // set 0 when reach bytesToNotify, notify progress
237+ LocationItemFile * source;
238+ LocationItemFile * target;
239+ QString targetName;
240+ bool isEntryItem; //true when the file being copied is at toplevel of the copy/cut operation
241+ qint64 amountSavedToRefresh;
242 };
243
244 /*!

Subscribers

People subscribed via source and target branches