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

Proposed by Carlos Jose Mazieri
Status: Merged
Approved by: Arto Jalkanen
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 Approve
Arto Jalkanen Approve
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.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
445. By Carlos Jose Mazieri

Fixed CMakeLists.txt

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Arto Jalkanen (ajalkane) :
review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/plugin/folderlistmodel/CMakeLists.txt'
--- src/plugin/folderlistmodel/CMakeLists.txt 2015-07-21 22:53:31 +0000
+++ src/plugin/folderlistmodel/CMakeLists.txt 2015-07-21 22:53:31 +0000
@@ -45,6 +45,8 @@
45 locationurl.h45 locationurl.h
46 locationitemdiriterator.cpp46 locationitemdiriterator.cpp
47 locationitemdiriterator.h47 locationitemdiriterator.h
48 locationitemfile.cpp
49 locationitemfile.h
48 cleanurl.cpp50 cleanurl.cpp
49 cleanurl.h51 cleanurl.h
50 urliteminfo.cpp52 urliteminfo.cpp
5153
=== modified file 'src/plugin/folderlistmodel/filesystemaction.cpp'
--- src/plugin/folderlistmodel/filesystemaction.cpp 2015-07-21 22:53:31 +0000
+++ src/plugin/folderlistmodel/filesystemaction.cpp 2015-07-21 22:53:31 +0000
@@ -40,7 +40,7 @@
40#include "location.h"40#include "location.h"
41#include "locationsfactory.h"41#include "locationsfactory.h"
42#include "locationitemdiriterator.h"42#include "locationitemdiriterator.h"
4343#include "locationitemfile.h"
4444
45#if defined(Q_OS_UNIX)45#if defined(Q_OS_UNIX)
46#include <sys/statvfs.h>46#include <sys/statvfs.h>
@@ -669,7 +669,9 @@
669 }669 }
670 else670 else
671 {671 {
672 m_cancelCurrentAction = !QFile::remove(fi.absoluteFilePath());672 LocationItemFile *qFile = m_curAction->sourceLocation->newFile(fi.absoluteFilePath());
673 m_cancelCurrentAction = !qFile->remove();
674 delete qFile;
673 }675 }
674#if DEBUG_REMOVE676#if DEBUG_REMOVE
675 qDebug() << Q_FUNC_INFO << "remove ret=" << !m_cancelCurrentAction << fi.absoluteFilePath();677 qDebug() << Q_FUNC_INFO << "remove ret=" << !m_cancelCurrentAction << fi.absoluteFilePath();
@@ -743,14 +745,17 @@
743 const DirItemInfo &fi = entry->reversedOrder.at(entry->currItem);745 const DirItemInfo &fi = entry->reversedOrder.at(entry->currItem);
744 QString orig = fi.absoluteFilePath();746 QString orig = fi.absoluteFilePath();
745 QString target = targetFrom(orig, entry);747 QString target = targetFrom(orig, entry);
748#if DEBUG_MESSAGES
749 qDebug() << "orig:" << orig << "target:" << target;
750#endif
746 QString path(target);751 QString path(target);
747 // do this here to allow progress send right item number, copySingleFile will emit progress()752 // do this here to allow progress send right item number, copySingleFile will emit progress()
748 m_curAction->currItem++;753 m_curAction->currItem++;
749 //--754 //--
750 if (fi.isFile() || fi.isSymLink())755 if (fi.isFile() || fi.isSymLink())
751 {756 {
752 DirItemInfo t(target);757 QScopedPointer <DirItemInfo> t(m_curAction->targetLocation->newItemInfo(target));
753 path = t.path();758 path = t->path();
754 }759 }
755 //check if the main item in the entry is a directory760 //check if the main item in the entry is a directory
756 //if so it needs to appear on any attached view761 //if so it needs to appear on any attached view
@@ -763,7 +768,7 @@
763 QDir entryDirObj(entryDir);768 QDir entryDirObj(entryDir);
764 if (!entryDirObj.exists() && entryDirObj.mkpath(entryDir))769 if (!entryDirObj.exists() && entryDirObj.mkpath(entryDir))
765 {770 {
766 QScopedPointer <DirItemInfo> item(m_locationsFactory->currentLocation()->newItemInfo(entryDir));771 QScopedPointer <DirItemInfo> item(m_curAction->targetLocation->newItemInfo(entryDir));
767 entry->added = true;772 entry->added = true;
768 notifyActionOnItem(*item, ItemAdded);773 notifyActionOnItem(*item, ItemAdded);
769 }774 }
@@ -789,8 +794,10 @@
789 else794 else
790 if (fi.isDir())795 if (fi.isDir())
791 {796 {
797 LocationItemFile *qFile = m_curAction->targetLocation->newFile(target);
792 m_cancelCurrentAction = !798 m_cancelCurrentAction = !
793 QFile(target).setPermissions(fi.permissions());799 qFile->setPermissions(fi.permissions());
800 delete qFile;
794 if (m_cancelCurrentAction)801 if (m_cancelCurrentAction)
795 {802 {
796 m_errorTitle = QObject::tr("Could not set permissions to dir");803 m_errorTitle = QObject::tr("Could not set permissions to dir");
@@ -803,7 +810,7 @@
803 {810 {
804 qint64 needsSize = 0;811 qint64 needsSize = 0;
805 m_curAction->copyFile.clear();812 m_curAction->copyFile.clear();
806 m_curAction->copyFile.source = new QFile(orig);813 m_curAction->copyFile.source = m_curAction->sourceLocation->newFile(orig);
807 m_cancelCurrentAction = !m_curAction->copyFile.source->open(QFile::ReadOnly);814 m_cancelCurrentAction = !m_curAction->copyFile.source->open(QFile::ReadOnly);
808 if (m_cancelCurrentAction)815 if (m_cancelCurrentAction)
809 { 816 {
@@ -814,7 +821,7 @@
814 {821 {
815 needsSize = m_curAction->copyFile.source->size();822 needsSize = m_curAction->copyFile.source->size();
816 //create destination823 //create destination
817 m_curAction->copyFile.target = new QFile(target); 824 m_curAction->copyFile.target = m_curAction->targetLocation->newFile(target);
818 m_curAction->copyFile.targetName = target;825 m_curAction->copyFile.targetName = target;
819 //first open it read-only to get its size if exists826 //first open it read-only to get its size if exists
820 if (m_curAction->copyFile.target->open(QFile::ReadOnly))827 if (m_curAction->copyFile.target->open(QFile::ReadOnly))
@@ -823,7 +830,7 @@
823 m_curAction->copyFile.target->close();830 m_curAction->copyFile.target->close();
824 }831 }
825 //check if there is disk space to copy source to target 832 //check if there is disk space to copy source to target
826 if (needsSize > 0 && !m_locationsFactory->currentLocation()->isThereDiskSpace(entry->itemPaths.targetPath(), needsSize))833 if (needsSize > 0 && !m_curAction->targetLocation->isThereDiskSpace(entry->itemPaths.targetPath(), needsSize))
827 {834 {
828 m_cancelCurrentAction = true;835 m_cancelCurrentAction = true;
829 m_errorTitle = QObject::tr("There is no space to copy");836 m_errorTitle = QObject::tr("There is no space to copy");
@@ -848,7 +855,7 @@
848 //depending on the file size it may take longer, the view needs to be informed855 //depending on the file size it may take longer, the view needs to be informed
849 if (m_curAction->copyFile.isEntryItem && !m_cancelCurrentAction)856 if (m_curAction->copyFile.isEntryItem && !m_cancelCurrentAction)
850 {857 {
851 QScopedPointer <DirItemInfo> item(m_locationsFactory->currentLocation()->newItemInfo(target));858 QScopedPointer <DirItemInfo> item(m_curAction->targetLocation->newItemInfo(target));
852 if (!entry->alreadyExists)859 if (!entry->alreadyExists)
853 { 860 {
854 entry->added = true;861 entry->added = true;
@@ -877,9 +884,7 @@
877 * \param entry884 * \param entry
878 */885 */
879void FileSystemAction::moveEntry(ActionEntry *entry)886void FileSystemAction::moveEntry(ActionEntry *entry)
880{887{
881 QFile file;
882
883 for(; !m_cancelCurrentAction &&888 for(; !m_cancelCurrentAction &&
884 entry->currStep < STEP_FILES &&889 entry->currStep < STEP_FILES &&
885 m_curAction->currItem < m_curAction->totalItems &&890 m_curAction->currItem < m_curAction->totalItems &&
@@ -889,36 +894,38 @@
889894
890 {895 {
891 const DirItemInfo &fi = entry->reversedOrder.at(entry->currItem);896 const DirItemInfo &fi = entry->reversedOrder.at(entry->currItem);
892 file.setFileName(fi.absoluteFilePath());897 QScopedPointer<LocationItemFile> file(m_curAction->sourceLocation->newFile(fi.absoluteFilePath()));
893 DirItemInfo targetInfo(entry->itemPaths.target());898 QScopedPointer<DirItemInfo> targetInfo(m_curAction->targetLocation->newItemInfo(entry->itemPaths.target()));
894 //rename will fail899 //rename will fail
895 if (targetInfo.exists())900 if (targetInfo->exists())
896 {901 {
897 //will not emit removed() neither added()902 //will not emit removed() neither added()
898 entry->added = true;903 entry->added = true;
899 if (targetInfo.isFile() || targetInfo.isSymLink())904 if (targetInfo->isFile() || targetInfo->isSymLink())
900 {905 {
901 if (!QFile::remove(targetInfo.absoluteFilePath()))906 QScopedPointer<LocationItemFile>
907 targetFile(m_curAction->sourceLocation->newFile(targetInfo->absoluteFilePath()));
908 if (!targetFile->remove())
902 {909 {
903 m_cancelCurrentAction = true;910 m_cancelCurrentAction = true;
904 m_errorTitle = QObject::tr("Could not remove the directory/file ") +911 m_errorTitle = QObject::tr("Could not remove the directory/file ") +
905 targetInfo.absoluteFilePath();912 targetInfo->absoluteFilePath();
906 m_errorMsg = ::strerror(errno);913 m_errorMsg = ::strerror(errno);
907 }914 }
908 }915 }
909 else916 else //only for local disk operations
910 if (targetInfo.isDir())917 if (targetInfo->isDir() && !m_curAction->isRemote())
911 {918 {
912 //move target to /tmp and remove it later by creating an Remove action919 //move target to /tmp and remove it later by creating an Remove action
913 //this will emit removed()920 //this will emit removed()
914 moveDirToTempAndRemoveItLater(targetInfo.absoluteFilePath());921 moveDirToTempAndRemoveItLater(targetInfo->absoluteFilePath());
915 }922 }
916 }923 }
917 if (!m_cancelCurrentAction && !file.rename(entry->itemPaths.target()))924 if (!m_cancelCurrentAction && !file->rename(entry->itemPaths.target()))
918 {925 {
919 m_cancelCurrentAction = true;926 m_cancelCurrentAction = true;
920 m_errorTitle = QObject::tr("Could not move the directory/file ") +927 m_errorTitle = QObject::tr("Could not move the directory/file ") +
921 targetInfo.absoluteFilePath();928 targetInfo->absoluteFilePath();
922 m_errorMsg = ::strerror(errno);929 m_errorMsg = ::strerror(errno);
923 }930 }
924 }//for931 }//for
@@ -1386,7 +1393,10 @@
1386#if defined(DEBUG_MESSAGES) || defined(REGRESSION_TEST_FOLDERLISTMODEL)1393#if defined(DEBUG_MESSAGES) || defined(REGRESSION_TEST_FOLDERLISTMODEL)
1387 qDebug() << Q_FUNC_INFO << dir << "being moved to" << tempDir;1394 qDebug() << Q_FUNC_INFO << dir << "being moved to" << tempDir;
1388#endif1395#endif
1389 if (QFile::rename(dir, tempDir))1396 LocationItemFile *qFile = m_curAction->targetLocation->newFile(dir);
1397 bool removed = qFile->rename(tempDir);
1398 delete qFile;
1399 if (removed)
1390 {1400 {
1391 if (m_curAction->auxAction == 0)1401 if (m_curAction->auxAction == 0)
1392 { // this new action as Remove will remove all dirs1402 { // this new action as Remove will remove all dirs
@@ -1424,7 +1434,7 @@
1424 {1434 {
1425 const DirItemInfo& fi =1435 const DirItemInfo& fi =
1426 entry->reversedOrder.at(entry->reversedOrder.count() -1);1436 entry->reversedOrder.at(entry->reversedOrder.count() -1);
1427 DirItemInfo backuped;1437 QScopedPointer<DirItemInfo> backuped(m_curAction->targetLocation->newItemInfo(QLatin1String(0)));
1428 int counter=0;1438 int counter=0;
1429 QString name;1439 QString name;
1430 do1440 do
@@ -1447,12 +1457,12 @@
1447 }1457 }
1448 }1458 }
1449 name.insert(pos,copy);1459 name.insert(pos,copy);
1450 backuped.setFile(fi.absolutePath(), name);1460 backuped->setFile(fi.absolutePath(), name);
1451 } while (backuped.exists() && counter < 100);1461 } while (backuped->exists() && counter < 100);
1452 if (counter < 100)1462 if (counter < 100)
1453 {1463 {
1454 entry->newName = new QString(backuped.fileName());1464 entry->newName = new QString(backuped->fileName());
1455 entry->itemPaths.setTargetFullName( backuped.absoluteFilePath() );1465 entry->itemPaths.setTargetFullName( backuped->absoluteFilePath() );
1456 ret = true;1466 ret = true;
1457 }1467 }
1458 }1468 }
14591469
=== modified file 'src/plugin/folderlistmodel/filesystemaction.h'
--- src/plugin/folderlistmodel/filesystemaction.h 2015-07-21 22:53:31 +0000
+++ src/plugin/folderlistmodel/filesystemaction.h 2015-07-21 22:53:31 +0000
@@ -49,7 +49,7 @@
49#define AMOUNT_COPIED_TO_REFRESH_ITEM_INFO 5000000049#define AMOUNT_COPIED_TO_REFRESH_ITEM_INFO 50000000
5050
51class DirModelMimeData;51class DirModelMimeData;
52class QFile;52class LocationItemFile;
53class QTemporaryFile;53class QTemporaryFile;
54class Location;54class Location;
55class LocationsFactory;55class LocationsFactory;
@@ -157,12 +157,12 @@
157 CopyFile();157 CopyFile();
158 ~CopyFile();158 ~CopyFile();
159 void clear();159 void clear();
160 qint64 bytesWritten; // set 0 when reach bytesToNotify, notify progress160 qint64 bytesWritten; // set 0 when reach bytesToNotify, notify progress
161 QFile * source;161 LocationItemFile * source;
162 QFile * target;162 LocationItemFile * target;
163 QString targetName;163 QString targetName;
164 bool isEntryItem; //true when the file being copied is at toplevel of the copy/cut operation164 bool isEntryItem; //true when the file being copied is at toplevel of the copy/cut operation
165 qint64 amountSavedToRefresh;165 qint64 amountSavedToRefresh;
166 };166 };
167167
168 /*!168 /*!

Subscribers

People subscribed via source and target branches