diff -U 3 -H -d -r -N -- Ultracopier-0.3/ListThread.cpp Rsync/ListThread.cpp --- Ultracopier-0.3/ListThread.cpp 2012-06-26 14:12:53.082114806 +0200 +++ Rsync/ListThread.cpp 2012-06-29 22:21:40.395733284 +0200 @@ -28,6 +28,7 @@ numberOfInodeOperation = 0; maxSpeed = 0; doRightTransfer = false; + rsync = false; keepDate = false; blockSize = 1024; osBufferLimit = 512; @@ -265,6 +266,21 @@ this->autoStart=autoStart; } +/// \brief set rsync +void ListThread::setRsync(const bool rsync) +{ + this->rsync=rsync; + int index=0; + loop_sub_size_transfer_thread_search=transferThreadList.size(); + while(indexsetRsync(rsync); + index++; + } + for(int i=0;isetRsync(rsync); +} + //set check destination folder void ListThread::setCheckDestinationFolderExists(const bool checkDestinationFolderExists) { @@ -327,11 +343,13 @@ #endif connect(scanFileOrFolderThreadsPool.last(),SIGNAL(newFolderListing(QString)), this,SIGNAL(newFolderListing(QString))); connect(scanFileOrFolderThreadsPool.last(),SIGNAL(addToRmPath(QString,int)), this,SLOT(addToRmPath(QString,int)), Qt::QueuedConnection); + connect(scanFileOrFolderThreadsPool.last(),SIGNAL(addToRmForRsync(QString)), this,SLOT(addToRmForRsync(QString)), Qt::QueuedConnection); connect(scanFileOrFolderThreadsPool.last(),SIGNAL(addToMkPath(QString)), this,SLOT(addToMkPath(QString)), Qt::QueuedConnection); connect(scanFileOrFolderThreadsPool.last(),SIGNAL(errorOnFolder(QFileInfo,QString)), this,SLOT(errorOnFolder(QFileInfo,QString)), Qt::QueuedConnection); connect(scanFileOrFolderThreadsPool.last(),SIGNAL(folderAlreadyExists(QFileInfo,QFileInfo,bool)), this,SLOT(folderAlreadyExists(QFileInfo,QFileInfo,bool)), Qt::QueuedConnection); + scanFileOrFolderThreadsPool.last()->setRsync(rsync); scanFileOrFolderThreadsPool.last()->setFilters(include,exclude); scanFileOrFolderThreadsPool.last()->setCheckDestinationFolderExists(checkDestinationFolderExists && alwaysDoThisActionForFolderExists!=FolderExists_Merge); if(scanFileOrFolderThreadsPool.size()==1) @@ -761,6 +779,18 @@ actionToDoListInode_afterTheTransfer << temp; } +//rsync rm +void ListThread::addToRmForRsync(const QString& inode) +{ + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"inode: "+inode); + actionToDoInode temp; + temp.type = ActionType_RmSync; + temp.id = generateIdNumber(); + temp.folder.setFile(inode); + temp.isRunning = false; + actionToDoListInode << temp; +} + //send action done void ListThread::sendActionDone() { @@ -1526,7 +1556,7 @@ loop_size=actionToDoListInode.size(); while(int_for_loopset_osBuffer(osBuffer); last->set_osBufferLimited(osBufferLimited); last->set_osBufferLimit(osBufferLimit); + last->setRsync(rsync); #ifdef ULTRACOPIER_PLUGIN_DEBUG connect(last,SIGNAL(debugInformation(DebugLevel,QString,QString,QString,int)),this,SIGNAL(debugInformation(DebugLevel,QString,QString,QString,int)), Qt::QueuedConnection); @@ -1669,7 +1700,7 @@ connect(last,SIGNAL(preOperationStopped()), this,SLOT(doNewActions_start_transfer()), Qt::QueuedConnection); connect(last,SIGNAL(postOperationStopped()), this,SLOT(transferInodeIsClosed()), Qt::QueuedConnection); connect(last,SIGNAL(checkIfItCanBeResumed()), this,SLOT(restartTransferIfItCan()), Qt::QueuedConnection); - connect(last,SIGNAL(pushStat(TransferStat,quint64)), this,SLOT(newTransferStat(TransferStat,quint64)), Qt::QueuedConnection); + connect(last,SIGNAL(pushStat(TransferStat,quint64)), this,SLOT(newTransferStat(TransferStat,quint64)), Qt::QueuedConnection); connect(this,SIGNAL(send_sendNewRenamingRules(QString,QString)), last,SLOT(setRenamingRules(QString,QString)), Qt::QueuedConnection); diff -U 3 -H -d -r -N -- Ultracopier-0.3/ListThread.h Rsync/ListThread.h --- Ultracopier-0.3/ListThread.h 2012-06-25 16:46:19.931261209 +0200 +++ Rsync/ListThread.h 2012-06-29 21:53:37.495762350 +0200 @@ -77,7 +77,8 @@ enum ActionType { ActionType_MkPath=1, - ActionType_RmPath=2 + ActionType_RmPath=2, + ActionType_RmSync=3 }; /// \brief to store one action to do struct actionToDoInode @@ -155,6 +156,8 @@ void setBlockSize(const int blockSize); /// \brief set auto start void setAutoStart(const bool autoStart); + /// \brief set rsync + void setRsync(const bool rsync); /// \brief set check destination folder void setCheckDestinationFolderExists(const bool checkDestinationFolderExists); /// \brief set data local to the thread @@ -196,6 +199,7 @@ quint64 bytesToTransfer; quint64 bytesTransfered; bool autoStart; + bool rsync; bool putInPause; QList actionDone;///< to action to send to the interface quint64 idIncrementNumber;///< to store the last id returned @@ -302,6 +306,8 @@ quint64 addToMkPath(const QString& folder); //add rm path to do void addToRmPath(const QString& folder,const int& inodeToRemove); + //rsync rm + void addToRmForRsync(const QString& inode); //send the progression, after full reset of the interface (then all is empty) void syncTransferList_internal(); signals: diff -U 3 -H -d -r -N -- Ultracopier-0.3/ListThread_InodeAction.cpp Rsync/ListThread_InodeAction.cpp --- Ultracopier-0.3/ListThread_InodeAction.cpp 2012-06-29 21:57:47.000000000 +0200 +++ Rsync/ListThread_InodeAction.cpp 2012-06-29 22:19:11.515735854 +0200 @@ -19,6 +19,14 @@ if(numberOfInodeOperation>=ULTRACOPIER_PLUGIN_MAXPARALLELINODEOPT) return; break; +case ActionType_RmSync: + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("launch rm to sync: %1").arg(currentActionToDoInode.folder.absoluteFilePath())); + rmPathQueue.addPath(currentActionToDoInode.folder.absoluteFilePath(),true); + currentActionToDoInode.isRunning=true; + numberOfInodeOperation++; + if(numberOfInodeOperation>=ULTRACOPIER_PLUGIN_MAXPARALLELINODEOPT) + return; +break; case ActionType_RmPath: /* What is this code? if((int_for_loop+number_rm_path_moved)>=(loop_size-1)) @@ -34,7 +42,7 @@ if(numberOfTranferRuning>0) ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,QString("skipped because already inode = 0 and transfer is running: %1").arg(currentActionToDoInode.folder.absoluteFilePath())); ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("launch rmpath: %1").arg(currentActionToDoInode.folder.absoluteFilePath())); - rmPathQueue.addPath(currentActionToDoInode.folder.absoluteFilePath()); + rmPathQueue.addPath(currentActionToDoInode.folder.absoluteFilePath(),false); currentActionToDoInode.isRunning=true; numberOfInodeOperation++; if(numberOfInodeOperation>=ULTRACOPIER_PLUGIN_MAXPARALLELINODEOPT) diff -U 3 -H -d -r -N -- Ultracopier-0.3/RmPath.cpp Rsync/RmPath.cpp --- Ultracopier-0.3/RmPath.cpp 2012-06-29 22:37:41.715716675 +0200 +++ Rsync/RmPath.cpp 2012-06-29 22:42:25.105711780 +0200 @@ -16,12 +16,12 @@ wait(); } -void RmPath::addPath(const QString &path) +void RmPath::addPath(const QString &path,const bool &toSync) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start: "+path); if(stopIt) return; - emit internalStartAddPath(path); + emit internalStartAddPath(path,toSync); } void RmPath::skip() @@ -38,7 +38,7 @@ void RmPath::run() { - connect(this,SIGNAL(internalStartAddPath(QString)),this,SLOT(internalAddPath(QString)),Qt::QueuedConnection); + 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); @@ -50,23 +50,63 @@ if(waitAction || pathList.isEmpty()) return; ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start: "+pathList.first()); - if(!rmpath(pathList.first())) + if(!toSyncList.first()) { - if(stopIt) + 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; - 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) +bool RmPath::rmpath(const QDir &dir,const bool &toSync) { if(!dir.exists()) return true; @@ -77,28 +117,40 @@ QFileInfo fileInfo(list.at(i)); if(!fileInfo.isDir()) { - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"found a file: "+fileInfo.fileName()); - allHaveWork=false; + 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()+'/')) + if(!rmpath(dir.absolutePath()+'/'+fileInfo.fileName()+'/',toSync)) allHaveWork=false; } } if(!allHaveWork) - return 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) +void RmPath::internalAddPath(const QString &path,const bool &toSync) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start: "+path); pathList << path; + toSyncList << toSync; if(!waitAction) checkIfCanDoTheNext(); } diff -U 3 -H -d -r -N -- Ultracopier-0.3/RmPath.h Rsync/RmPath.h --- Ultracopier-0.3/RmPath.h 2012-03-19 17:34:43.572371290 +0100 +++ Rsync/RmPath.h 2012-06-29 22:36:02.135718395 +0200 @@ -24,11 +24,11 @@ explicit RmPath(); ~RmPath(); /// \brief add new path to remove - void addPath(const QString &path); + void addPath(const QString &path,const bool &toSync); signals: void errorOnFolder(const QFileInfo &,const QString &); void firstFolderFinish(); - void internalStartAddPath(const QString &path); + void internalStartAddPath(const QString &path,const bool &toSync); void internalStartDoThisPath(); void internalStartSkip(); void internalStartRetry(); @@ -42,12 +42,14 @@ bool stopIt; bool skipIt; QStringList pathList; + QList toSyncList; void checkIfCanDoTheNext(); QDir dir; - bool rmpath(const QDir &dir); + bool rmpath(const QDir &dir,const bool &toSync); + bool rmfile(QString filePath); private slots: void internalDoThisPath(); - void internalAddPath(const QString &path); + void internalAddPath(const QString &path,const bool &toSync); void internalSkip(); void internalRetry(); }; diff -U 3 -H -d -r -N -- Ultracopier-0.3/TransferThread.cpp Rsync/TransferThread.cpp --- Ultracopier-0.3/TransferThread.cpp 2012-06-29 15:58:31.546130402 +0200 +++ Rsync/TransferThread.cpp 2012-06-29 18:58:24.095943961 +0200 @@ -26,6 +26,7 @@ alwaysDoFileExistsAction= FileExists_NotSet; readError = false; writeError = false; + rsync = false; this->mkpathTransfer = mkpathTransfer; readThread.setWriteThread(&writeThread); @@ -278,7 +279,7 @@ { //check if destination exists ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"["+QString::number(id)+"] overwrite: "+QString::number(fileExistsAction)+", always action: "+QString::number(alwaysDoFileExistsAction)); - if(alwaysDoFileExistsAction==FileExists_Overwrite || readError || writeError) + if(alwaysDoFileExistsAction==FileExists_Overwrite || rsync || readError || writeError) return false; if(destinationInfo.exists()) { @@ -1124,6 +1125,12 @@ emit tryPutAtBottom(); } +/// \brief set rsync +void TransferThread::setRsync(const bool rsync) +{ + this->rsync=rsync; +} + void TransferThread::set_osBufferLimit(unsigned int osBufferLimit) { this->osBufferLimit=osBufferLimit; diff -U 3 -H -d -r -N -- Ultracopier-0.3/TransferThread.h Rsync/TransferThread.h --- Ultracopier-0.3/TransferThread.h 2012-06-26 11:10:54.541994070 +0200 +++ Rsync/TransferThread.h 2012-06-29 15:54:29.286134585 +0200 @@ -113,6 +113,8 @@ qint64 copiedSize(); /// \brief put the current file at bottom void putAtBottom(); + /// \brief set rsync + void setRsync(const bool rsync); void set_osBufferLimit(unsigned int osBufferLimit); void setRenamingRules(QString firstRenamingRule,QString otherRenamingRule); @@ -166,6 +168,7 @@ bool readIsClosedVariable; bool writeIsClosedVariable; bool canBeMovedDirectlyVariable; + bool rsync; QByteArray sourceChecksum,destinationChecksum; volatile bool stopIt; volatile bool canStartTransfer; diff -U 3 -H -d -r -N -- Ultracopier-0.3/copyEngine.cpp Rsync/copyEngine.cpp --- Ultracopier-0.3/copyEngine.cpp 2012-06-26 14:14:40.892116001 +0200 +++ Rsync/copyEngine.cpp 2012-06-29 21:22:50.945794251 +0200 @@ -186,6 +186,7 @@ connect(ui->keepDate, SIGNAL(toggled(bool)), &threadOfTheTransfer, SLOT(setKeepDate(bool))); connect(ui->blockSize, SIGNAL(valueChanged(int)), &threadOfTheTransfer, SLOT(setBlockSize(int)));*/ connect(ui->autoStart, SIGNAL(toggled(bool)), this, SLOT(setAutoStart(bool))); + connect(ui->rsync, SIGNAL(toggled(bool)), this, SLOT(setRsync(bool))); connect(ui->checkBoxDestinationFolderExists, SIGNAL(toggled(bool)), this, SLOT(setCheckDestinationFolderExists(bool))); uiIsInstalled=true; setRightTransfer(doRightTransfer); @@ -193,6 +194,7 @@ setSpeedLimitation(maxSpeed); setBlockSize(blockSize); setAutoStart(autoStart); + setRsync(rsync); setCheckDestinationFolderExists(checkDestinationFolderExists); set_doChecksum(doChecksum); set_checksumIgnoreIfImpossible(checksumIgnoreIfImpossible); @@ -216,6 +218,7 @@ connect(ui->keepDate, SIGNAL(toggled(bool)), this,SLOT(setKeepDate(bool))); connect(ui->blockSize, SIGNAL(valueChanged(int)), this,SLOT(setBlockSize(int))); connect(ui->autoStart, SIGNAL(toggled(bool)), this,SLOT(setAutoStart(bool))); + connect(ui->rsync, SIGNAL(toggled(bool)), this,SLOT(setRsync(bool))); connect(ui->doChecksum, SIGNAL(toggled(bool)), this,SLOT(doChecksum_toggled(bool))); connect(ui->checksumIgnoreIfImpossible, SIGNAL(toggled(bool)), this,SLOT(checksumIgnoreIfImpossible_toggled(bool))); connect(ui->checksumOnlyOnError, SIGNAL(toggled(bool)), this,SLOT(checksumOnlyOnError_toggled(bool))); @@ -505,6 +508,13 @@ /** \brief give the forced mode, to export/import transfer list */ void copyEngine::forceMode(const CopyMode &mode) { + if(mode==Move) + { + listThread->setRsync(false); + rsync=false; + } + if(uiIsInstalled) + ui->rsync->setEnabled(mode==Copy); if(forcedMode) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,QString("Mode forced previously")); @@ -617,6 +627,19 @@ listThread->setAutoStart(autoStart); } +/// \brief set rsync +void copyEngine::setRsync(const bool rsync) +{ + this->rsync=rsync; + if(uiIsInstalled) + { + ui->rsync->setChecked(rsync); + ui->rsync->setEnabled(forcedMode && mode==Copy); + ui->label_rsync->setEnabled(forcedMode && mode==Copy); + } + listThread->setRsync(rsync); +} + //set check destination folder void copyEngine::setCheckDestinationFolderExists(const bool checkDestinationFolderExists) { diff -U 3 -H -d -r -N -- Ultracopier-0.3/copyEngine.h Rsync/copyEngine.h --- Ultracopier-0.3/copyEngine.h 2012-06-25 16:50:12.191263770 +0200 +++ Rsync/copyEngine.h 2012-06-29 15:49:45.856139485 +0200 @@ -60,6 +60,7 @@ bool keepDate; int blockSize; bool autoStart; + bool rsync; bool checkDestinationFolderExists; FileExistsAction alwaysDoThisActionForFileExists; FileErrorAction alwaysDoThisActionForFileError; @@ -273,6 +274,8 @@ void setBlockSize(const int blockSize); /// \brief set auto start void setAutoStart(const bool autoStart); + /// \brief set rsync + void setRsync(const bool rsync); /// \brief set if need check if the destination folder exists void setCheckDestinationFolderExists(const bool checkDestinationFolderExists); /// \brief reset widget diff -U 3 -H -d -r -N -- Ultracopier-0.3/copyEngine.pro.user Rsync/copyEngine.pro.user --- Ultracopier-0.3/copyEngine.pro.user 2012-06-26 15:50:53.722179836 +0200 +++ Rsync/copyEngine.pro.user 2012-06-29 22:42:24.025711798 +0200 @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -163,7 +163,113 @@ 2 true - 2 + + ProjectExplorer.ToolChain.Gcc:{d6ee78f7-3364-4f54-a93f-b3c1e2a8c8c9} + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + true + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt 5.0.0 (qt-everywhere-opensource-src-5.0.0) Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/user/Desktop/ultracopier/sources/plugins/CopyEngine/copyEngine-build-desktop-Qt_5_0_0__qt-everywhere-opensource-src-5_0_0__Release + 3 + true + + + ProjectExplorer.ToolChain.Gcc:{d6ee78f7-3364-4f54-a93f-b3c1e2a8c8c9} + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + true + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt 5.0.0 (qt-everywhere-opensource-src-5.0.0) Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/user/Desktop/ultracopier/sources/plugins/CopyEngine/copyEngine-build-desktop-Qt_5_0_0__qt-everywhere-opensource-src-5_0_0__Debug + 3 + true + + 4 0 diff -U 3 -H -d -r -N -- Ultracopier-0.3/factory.cpp Rsync/factory.cpp --- Ultracopier-0.3/factory.cpp 2012-06-26 14:10:39.972113336 +0200 +++ Rsync/factory.cpp 2012-06-29 15:40:43.606148853 +0200 @@ -35,6 +35,7 @@ connect(ui->keepDate, SIGNAL(toggled(bool)), this,SLOT(setKeepDate(bool))); connect(ui->blockSize, SIGNAL(valueChanged(int)), this,SLOT(setBlockSize(int))); connect(ui->autoStart, SIGNAL(toggled(bool)), this,SLOT(setAutoStart(bool))); + connect(ui->rsync, SIGNAL(toggled(bool)), this,SLOT(setRsync(bool))); connect(ui->doChecksum, SIGNAL(toggled(bool)), this,SLOT(doChecksum_toggled(bool))); connect(ui->checksumIgnoreIfImpossible, SIGNAL(toggled(bool)), this,SLOT(checksumIgnoreIfImpossible_toggled(bool))); connect(ui->checksumOnlyOnError, SIGNAL(toggled(bool)), this,SLOT(checksumOnlyOnError_toggled(bool))); @@ -71,6 +72,7 @@ realObject->setKeepDate( optionsEngine->getOptionValue("keepDate").toBool()); realObject->setBlockSize( optionsEngine->getOptionValue("blockSize").toInt()); realObject->setAutoStart( optionsEngine->getOptionValue("autoStart").toBool()); + realObject->setRsync( optionsEngine->getOptionValue("rsync").toBool()); realObject->on_comboBoxFolderColision_currentIndexChanged(ui->comboBoxFolderColision->currentIndex()); realObject->on_comboBoxFolderError_currentIndexChanged(ui->comboBoxFolderError->currentIndex()); realObject->setCheckDestinationFolderExists( optionsEngine->getOptionValue("checkDestinationFolder").toBool()); @@ -123,6 +125,7 @@ KeysList.append(qMakePair(QString("keepDate"),QVariant(true))); KeysList.append(qMakePair(QString("blockSize"),QVariant(1024)));//1024KB as default KeysList.append(qMakePair(QString("autoStart"),QVariant(true))); + KeysList.append(qMakePair(QString("rsync"),QVariant(true))); KeysList.append(qMakePair(QString("folderError"),QVariant(0))); KeysList.append(qMakePair(QString("folderColision"),QVariant(0))); KeysList.append(qMakePair(QString("checkDestinationFolder"),QVariant(true))); @@ -151,6 +154,7 @@ ui->keepDate->setChecked(optionsEngine->getOptionValue("keepDate").toBool()); ui->blockSize->setValue(optionsEngine->getOptionValue("blockSize").toUInt()); ui->autoStart->setChecked(optionsEngine->getOptionValue("autoStart").toBool()); + ui->rsync->setChecked(optionsEngine->getOptionValue("rsync").toBool()); ui->comboBoxFolderError->setCurrentIndex(optionsEngine->getOptionValue("folderError").toUInt()); ui->comboBoxFolderColision->setCurrentIndex(optionsEngine->getOptionValue("folderColision").toUInt()); ui->checkBoxDestinationFolderExists->setChecked(optionsEngine->getOptionValue("checkDestinationFolder").toBool()); @@ -287,6 +291,15 @@ else ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented"); } + +void Factory::setRsync(bool rsync) +{ + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"the checkbox have changed"); + if(optionsEngine!=NULL) + optionsEngine->setOptionValue("rsync",rsync); + else + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented"); +} void Factory::newLanguageLoaded() { diff -U 3 -H -d -r -N -- Ultracopier-0.3/factory.h Rsync/factory.h --- Ultracopier-0.3/factory.h 2012-05-19 15:44:05.354039716 +0200 +++ Rsync/factory.h 2012-06-29 15:40:20.016149261 +0200 @@ -71,6 +71,7 @@ void setKeepDate(bool keepDate); void setBlockSize(int blockSize); void setAutoStart(bool autoStart); + void setRsync(bool rsync); void showFilterDialog(); void sendNewFilters(QStringList includeStrings,QStringList includeOptions,QStringList excludeStrings,QStringList excludeOptions); void doChecksum_toggled(bool); diff -U 3 -H -d -r -N -- Ultracopier-0.3/informations.xml Rsync/informations.xml --- Ultracopier-0.3/informations.xml 2012-06-25 17:31:49.331291383 +0200 +++ Rsync/informations.xml 2012-06-29 15:11:53.696178734 +0200 @@ -1,7 +1,7 @@ - <![CDATA[Copy engine of Ultracopier 0.3]]> - <![CDATA[Moteur de copie d'ultracopier 0.3]]> + <![CDATA[Rsync copy engine]]> + <![CDATA[Moteur de copie rsync]]> CopyEngine @@ -14,12 +14,12 @@ linux-x86_64-pc - - + + 0.3.0.10 - Ultracopier-0.3 + Rsync =ultracopier-0.3.0.10 diff -U 3 -H -d -r -N -- Ultracopier-0.3/options.ui Rsync/options.ui --- Ultracopier-0.3/options.ui 2012-06-20 14:56:21.509908805 +0200 +++ Rsync/options.ui 2012-06-29 22:15:47.595739375 +0200 @@ -6,8 +6,8 @@ 0 0 - 356 - 376 + 354 + 399 @@ -122,7 +122,7 @@ - + Checksum @@ -175,24 +175,24 @@ - + Enable OS buffer - + - + OS buffer only if smaller than - + KB @@ -215,7 +215,7 @@ - + Qt::Vertical @@ -228,20 +228,34 @@ - + Filters - + Renaming rules + + + + + + + + + + + Rsync (only in copy mode) + + + diff -U 3 -H -d -r -N -- Ultracopier-0.3/scanFileOrFolder.cpp Rsync/scanFileOrFolder.cpp --- Ultracopier-0.3/scanFileOrFolder.cpp 2012-05-23 11:06:25.001037392 +0200 +++ Rsync/scanFileOrFolder.cpp 2012-06-29 21:54:15.555761695 +0200 @@ -1,9 +1,10 @@ #include "scanFileOrFolder.h" -#include +#include scanFileOrFolder::scanFileOrFolder(CopyMode mode) { + rsync=false; stopped = true; stopIt = false; this->mode=mode; @@ -427,7 +428,17 @@ if(!included) {} else - emit fileTransfer(fileInfo.absoluteFilePath(),finalDest+fileName,mode); + { + bool sendToTransfer=false; + if(!rsync) + sendToTransfer=true; + else if(!QFile::exists(finalDest+fileName)) + sendToTransfer=true; + else if(fileInfo.lastModified()!=QFileInfo(finalDest+fileName).lastModified()) + sendToTransfer=true; + if(sendToTransfer) + emit fileTransfer(fileInfo.absoluteFilePath(),finalDest+fileName,mode); + } } } } @@ -437,9 +448,43 @@ //listFolder(source,destination,suffixPath+fileInfo.fileName()+QDir::separator()); listFolder(source,destination,sourceSuffixPath+fileInfo.fileName()+"/",destinationSuffixPath+fileInfo.fileName()+"/");//put unix separator because it's transformed into that's under windows too else - emit fileTransfer(fileInfo.absoluteFilePath(),finalDest+fileInfo.fileName(),mode); + { + bool sendToTransfer=false; + if(!rsync) + sendToTransfer=true; + else if(!QFile::exists(finalDest+fileInfo.fileName())) + sendToTransfer=true; + else if(fileInfo.lastModified()!=QFileInfo(finalDest+fileInfo.fileName()).lastModified()) + sendToTransfer=true; + if(sendToTransfer) + emit fileTransfer(fileInfo.absoluteFilePath(),finalDest+fileInfo.fileName(),mode); + } } } + if(rsync) + { + //check the reverse path here + QFileInfoList entryListDestination=QDir(finalDest).entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden|QDir::System,QDir::DirsFirst|QDir::Name|QDir::IgnoreCase);//possible wait time here + int sizeEntryListDestination=entryListDestination.size(); + int index=0; + for (int indexDestination=0;indexDestinationfirstRenamingRule=firstRenamingRule; this->otherRenamingRule=otherRenamingRule; } + +/// \brief set rsync +void scanFileOrFolder::setRsync(const bool rsync) +{ + this->rsync=rsync; +} diff -U 3 -H -d -r -N -- Ultracopier-0.3/scanFileOrFolder.h Rsync/scanFileOrFolder.h --- Ultracopier-0.3/scanFileOrFolder.h 2012-05-20 20:32:43.695874620 +0200 +++ Rsync/scanFileOrFolder.h 2012-06-29 21:51:45.235764294 +0200 @@ -38,6 +38,8 @@ /// \brief set if need check if the destination exists void setCheckDestinationFolderExists(const bool checkDestinationFolderExists); void setRenamingRules(QString firstRenamingRule,QString otherRenamingRule); + /// \brief set rsync + void setRsync(const bool rsync); signals: void fileTransfer(const QFileInfo &source,const QFileInfo &destination,const CopyMode &mode); /// \brief To debug source @@ -49,6 +51,7 @@ void newFolderListing(const QString &path); void addToMkPath(const QString& folder); void addToRmPath(const QString& folder,const int& inodeToRemove); + void addToRmForRsync(const QString& inode); public slots: void addToList(const QStringList& sources,const QString& destination); void setFilters(QList include,QList exclude); @@ -69,6 +72,7 @@ QString prefix; QString suffix; CopyMode mode; + bool rsync; QList include,exclude; QList include_send,exclude_send; bool reloadTheNewFilters;