-
Notifications
You must be signed in to change notification settings - Fork 1
/
worker.cpp
35 lines (33 loc) · 1.02 KB
/
worker.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "worker.h"
#include "utils.h"
void Worker::doWork(QString sourcePath, QString newPath, QString targetPath)
{
QList<QString> r = getFullDirectory(newPath);
for (int i = 0;i < r.length();++i)
{
QString newFilePath = QString(r.at(i));
QString sourceFilePath = QString(r.at(i)).replace(newPath, sourcePath);
QFile sourceFile(sourceFilePath);
bool isNew = false;
if (sourceFile.exists())
{
if (getHash(sourceFilePath) != getHash(newFilePath))
{
isNew = true;
}
}
else
{
isNew = true;
}
if (isNew)
{
QString targetFilePath = QString(r.at(i)).replace(newPath, targetPath);
QFileInfo fi = QFileInfo(targetFilePath);
verifyOrCreateTargetDirectory(fi.absolutePath());
QFile::copy(newFilePath, targetFilePath);
}
workProgress(i, r.length());
}
workFinished();
}