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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// *****************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0 *
// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
// *****************************************************************************
#ifndef SYNCHRONIZATION_H_8913470815943295
#define SYNCHRONIZATION_H_8913470815943295
#include <chrono>
//#include "config.h"
#include "structures.h"
#include "file_hierarchy.h"
#include "process_callback.h"
namespace fff
{
class SyncStatistics //this class counts *logical* operations, (create, update, delete + bytes), *not* disk accesses!
{
//-> note the fundamental difference compared to counting disk accesses!
public:
SyncStatistics(const FolderComparison& folderCmp);
SyncStatistics(const ContainerObject& hierObj);
SyncStatistics(const FilePair& file);
template <SelectedSide side>
int createCount() const { return SelectParam<side>::ref(createLeft_, createRight_); }
int createCount() const { return createLeft_ + createRight_; }
template <SelectedSide side>
int updateCount() const { return SelectParam<side>::ref(updateLeft_, updateRight_); }
int updateCount() const { return updateLeft_ + updateRight_; }
template <SelectedSide side>
int deleteCount() const { return SelectParam<side>::ref(deleteLeft_, deleteRight_); }
int deleteCount() const { return deleteLeft_ + deleteRight_; }
template <SelectedSide side>
bool expectPhysicalDeletion() const { return SelectParam<side>::ref(physicalDeleteLeft_, physicalDeleteRight_); }
int64_t getBytesToProcess() const { return bytesToProcess_; }
size_t rowCount () const { return rowsTotal_; }
struct ConflictInfo
{
Zstring relPath;
std::wstring msg;
};
const std::vector<ConflictInfo>& getConflictsPreview() const { return conflictsPreview_; }
int conflictCount() const { return conflictCount_; }
private:
void recurse(const ContainerObject& hierObj);
void processFile (const FilePair& file);
void processLink (const SymlinkPair& link);
void processFolder(const FolderPair& folder);
int createLeft_ = 0;
int createRight_ = 0;
int updateLeft_ = 0;
int updateRight_ = 0;
int deleteLeft_ = 0;
int deleteRight_ = 0;
bool physicalDeleteLeft_ = false; //at least 1 item will be deleted; considers most "update" cases which also delete items
bool physicalDeleteRight_ = false; //
int64_t bytesToProcess_ = 0;
size_t rowsTotal_ = 0;
int conflictCount_ = 0;
std::vector<ConflictInfo> conflictsPreview_; //conflict texts to display as a warning message
static const size_t SYNC_STATS_CONFLICTS_MAX = 25; //=> consider memory consumption, log file size, email size!
//limit conflict count! e.g. there may be hundred thousands of "same date but a different size"
};
struct FolderPairSyncCfg
{
DirectionConfig::Variant syncVariant;
bool saveSyncDB; //save database if in automatic mode or dection of moved files is active
DeletionPolicy handleDeletion;
Zstring versioningFolderPhrase; //unresolved directory names as entered by user!
VersioningStyle versioningStyle;
int versionMaxAgeDays;
int versionCountMin;
int versionCountMax;
};
std::vector<FolderPairSyncCfg> extractSyncCfg(const MainConfiguration& mainCfg);
//FFS core routine:
void synchronize(const std::chrono::system_clock::time_point& syncStartTime,
bool verifyCopiedFiles,
bool copyLockedFiles,
bool copyFilePermissions,
bool failSafeFileCopy,
bool runWithBackgroundPriority,
const std::vector<FolderPairSyncCfg>& syncConfig, //CONTRACT: syncConfig and folderCmp correspond row-wise!
FolderComparison& folderCmp, //
WarningDialogs& warnings,
ProcessCallback& callback);
}
#endif //SYNCHRONIZATION_H_8913470815943295
|