diff options
author | Thomas Preud'homme <robotux@celest.fr> | 2017-11-24 23:24:09 +0000 |
---|---|---|
committer | Thomas Preud'homme <robotux@celest.fr> | 2017-11-24 23:24:09 +0000 |
commit | b3c8bdcc0d1e4b2ab298847a7902b6d60410a5bc (patch) | |
tree | 8fce8a51adfb245db8ab2a76831661780c0c713e /plugins-alternative/CopyEngine/Rsync/RmPath.cpp | |
parent | e297dbd8052ef4e66f069e2dd1865ae7fa8af28e (diff) |
New upstream version 1.2.3.6
Diffstat (limited to 'plugins-alternative/CopyEngine/Rsync/RmPath.cpp')
-rw-r--r-- | plugins-alternative/CopyEngine/Rsync/RmPath.cpp | 179 |
1 files changed, 0 insertions, 179 deletions
diff --git a/plugins-alternative/CopyEngine/Rsync/RmPath.cpp b/plugins-alternative/CopyEngine/Rsync/RmPath.cpp deleted file mode 100644 index 636b5ba..0000000 --- a/plugins-alternative/CopyEngine/Rsync/RmPath.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#include "RmPath.h" - -RmPath::RmPath() -{ - stopIt=false; - waitAction=false; - setObjectName("RmPath"); - moveToThread(this); - start(); -} - -RmPath::~RmPath() -{ - stopIt=true; - quit(); - wait(); -} - -void RmPath::addPath(const QString &path,const bool &toSync) -{ - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start: "+path); - if(stopIt) - return; - emit internalStartAddPath(path,toSync); -} - -void RmPath::skip() -{ - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); - emit internalStartSkip(); -} - -void RmPath::retry() -{ - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); - emit internalStartRetry(); -} - -void RmPath::run() -{ - connect(this,SIGNAL(internalStartAddPath(QString,bool)),this,SLOT(internalAddPath(QString,bool)),Qt::QueuedConnection); - connect(this,SIGNAL(internalStartDoThisPath()),this,SLOT(internalDoThisPath()),Qt::QueuedConnection); - connect(this,SIGNAL(internalStartSkip()),this,SLOT(internalSkip()),Qt::QueuedConnection); - connect(this,SIGNAL(internalStartRetry()),this,SLOT(internalRetry()),Qt::QueuedConnection); - exec(); -} - -void RmPath::internalDoThisPath() -{ - if(waitAction || pathList.isEmpty()) - return; - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start: "+pathList.first()); - if(!toSyncList.first()) - { - if(!rmpath(pathList.first(),false)) - { - if(stopIt) - return; - waitAction=true; - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"Unable to remove the folder: "+pathList.first()); - emit errorOnFolder(pathList.first(),tr("Unable to remove the folder")); - return; - } - } - else - { - if(QFileInfo(pathList.first()).isDir()) - { - if(!rmpath(pathList.first(),true)) - { - if(stopIt) - return; - waitAction=true; - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"Unable to remove the folder: "+pathList.first()); - emit errorOnFolder(pathList.first(),tr("Unable to remove the folder")); - return; - } - } - else if(!rmfile(pathList.first())) - { - if(stopIt) - return; - waitAction=true; - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"Unable to remove the file: "+pathList.first()); - emit errorOnFolder(pathList.first(),tr("Unable to remove the file")); - return; - } - } - pathList.removeFirst(); - toSyncList.removeFirst(); - emit firstFolderFinish(); - checkIfCanDoTheNext(); -} - -bool RmPath::rmfile(QString filePath) -{ - QFile file(filePath); - if(!file.remove()) - { - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"unable to remove the file: "+file.fileName()+", error: "+file.errorString()); - return false; - } - else - return true; -} - -/** remplace QDir::rmpath() because it return false if the folder not exists - and seam bug with parent folder */ -bool RmPath::rmpath(const QDir &dir,const bool &toSync) -{ - if(!dir.exists()) - return true; - bool allHaveWork=true; - QFileInfoList list = dir.entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden|QDir::System,QDir::DirsFirst); - for (int i = 0; i < list.size(); ++i) - { - QFileInfo fileInfo(list.at(i)); - if(!fileInfo.isDir()) - { - if(toSync) - { - if(!rmfile(fileInfo.absoluteFilePath())) - { - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"unable to remove a file: "+fileInfo.fileName()); - allHaveWork=false; - } - } - else - { - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"found a file: "+fileInfo.fileName()); - allHaveWork=false; - } - } - else - { - //return the fonction for scan the new folder - if(!rmpath(dir.absolutePath()+'/'+fileInfo.fileName()+'/',toSync)) - allHaveWork=false; - } - } - if(!allHaveWork) - return false; - allHaveWork=dir.rmdir(dir.absolutePath()); - if(!allHaveWork) - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"unable to remove the folder: "+dir.absolutePath()); - return allHaveWork; -} - -void RmPath::internalAddPath(const QString &path,const bool &toSync) -{ - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start: "+path); - pathList << path; - toSyncList << toSync; - if(!waitAction) - checkIfCanDoTheNext(); -} - -void RmPath::checkIfCanDoTheNext() -{ - if(!waitAction && !stopIt && pathList.size()>0) - emit internalStartDoThisPath(); -} - -void RmPath::internalSkip() -{ - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); - waitAction=false; - pathList.removeFirst(); - emit firstFolderFinish(); - checkIfCanDoTheNext(); -} - -void RmPath::internalRetry() -{ - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); - waitAction=false; - checkIfCanDoTheNext(); -} - |