[Companion] SD Sync reworked: (#4906)
* Complete re-write of SyncProcess, now more robust, UI-independent, runs in own thread, large speed boost;
* Use file hash comparisons instead of byte-level compare with string methods (probable fixes for #4837 and #4848);
* New pre-sync options dialog with selectable folders and other settings (settings are remembered until app exit);
* Option to choose sync direction(s) (up/down/bi) and the order in which bi-directional sync runs;
* Option to choose file comparison mode (timestamp/hash/both) or force overwrite (for one-way sync);
* Option to set a maximum file size to copy;
* Option to do a test run w/out actually copying any files;
* Better reporting of progress, total counts (copied/updated/skipped), and errors, with color coding;
* Much more reliable to cancel long-running/hung copy process;
* ProgressWidget can now display rich-text in the text browser, added some new functions for usage;
* Misc. small layout tweaks to ProgressDialog and ProgressWidget to make them behave/look better;
This commit is contained in:
committed by
Bertrand Songis
parent
ca25696d1a
commit
c1586b72bb
@@ -22,34 +22,72 @@
|
||||
#define _PROCESS_SYNC_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
#include <QMutex>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
class QDir;
|
||||
class ProgressWidget;
|
||||
|
||||
class SyncProcess : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SyncProcess(const QString & folder1, const QString & folder2, ProgressWidget * progress);
|
||||
bool run();
|
||||
enum SyncDirection {
|
||||
SYNC_A2B_B2A,
|
||||
SYNC_B2A_A2B,
|
||||
SYNC_A2B,
|
||||
SYNC_B2A
|
||||
};
|
||||
|
||||
protected slots:
|
||||
void onClosed();
|
||||
enum SyncCompareType {
|
||||
OVERWR_NEWER_IF_DIFF,
|
||||
OVERWR_NEWER_ALWAYS,
|
||||
OVERWR_IF_DIFF,
|
||||
OVERWR_ALWAYS
|
||||
};
|
||||
|
||||
SyncProcess(const QString & folderA,
|
||||
const QString & folderB,
|
||||
const int & syncDirection = SYNC_A2B_B2A,
|
||||
const int & compareType = OVERWR_NEWER_IF_DIFF,
|
||||
const qint64 & maxFileSize = 5*1024*1024,
|
||||
const bool dryRun = false);
|
||||
|
||||
public slots:
|
||||
void run();
|
||||
void stop();
|
||||
|
||||
signals:
|
||||
void started();
|
||||
void finished();
|
||||
void fileCountChanged(int count);
|
||||
void progressStep(int step);
|
||||
void progressMessage(const QString & text, const int & type);
|
||||
void statusMessage(const QString & text);
|
||||
|
||||
protected:
|
||||
bool isStopRequsted();
|
||||
void finish();
|
||||
int getFilesCount(const QString & directory);
|
||||
QStringList updateDir(const QString & source, const QString & destination);
|
||||
QString updateEntry(const QString & path, const QDir & source, const QDir & destination);
|
||||
void updateDir(const QString & source, const QString & destination);
|
||||
bool updateEntry(const QString & entry, const QDir & source, const QDir & destination);
|
||||
|
||||
QString folder1;
|
||||
QString folder2;
|
||||
ProgressWidget * progress;
|
||||
QStringList errors;
|
||||
SyncDirection direction;
|
||||
SyncCompareType ctype;
|
||||
qint64 maxFileSize; // Bytes
|
||||
QDir::Filters dirFilters;
|
||||
QMutex stopReqMutex;
|
||||
QString reportTemplate;
|
||||
QString testRunStr;
|
||||
int index;
|
||||
int count;
|
||||
bool closed;
|
||||
int created;
|
||||
int updated;
|
||||
int skipped;
|
||||
int errored;
|
||||
bool dryRun;
|
||||
bool stopping;
|
||||
};
|
||||
|
||||
#endif // _PROCESS_SYNC_H_
|
||||
|
||||
Reference in New Issue
Block a user