Debian Codegraph @

src/job_options.cpp

raw symbols SCIP
1 #include "job_options.h"
2 #include "utils.h"
3 #include <qexception.h>
4 #include <qlogging.h>
5 #ifdef _WIN32
6 #pragma warning(disable : 4505)
7 #endif
8 JobOptions::JobOptions(bool isDownload) : JobOptions() {
9 setJobType(isDownload);
10 uniqueId = QUuid::createUuid();
11 }
12
13 JobOptions::JobOptions()
14 : jobType(UnknownJobType), operation(UnknownOp), dryRun(false), sync(false),
15 syncTiming(UnknownTiming), skipNewer(false), skipExisting(false),
16 compare(false), compareOption(), verbose(false), sameFilesystem(false),
17 dontUpdateModified(false), maxDepth(0), deleteExcluded(false),
18 isFolder(false) {}
19
20 const qint32 JobOptions::classVersion = 3;
21
22 JobOptions::~JobOptions() {}
23
24 /*
25 * Turn the options held here into a string list for
26 * use in the rclone command.
27 *
28 * This logic was originally in transfer_dialog.cpp.
29 *
30 * This needs to change whenever e.g. new options are
31 * added to the dialog.
32 */
33 QStringList JobOptions::getOptions() const {
34 QStringList list;
35
36 if (operation == Copy) {
37 list << "copy";
38 } else if (operation == Move) {
39 list << "move";
40 } else if (operation == Sync) {
41 list << "sync";
42 }
43
44 if (dryRun) {
45 list << "--dry-run";
46 }
47
48 if (sync) {
49 switch (syncTiming) {
50 case During:
51 list << "--delete-during";
52 break;
53 case After:
54 list << "--delete-after";
55 break;
56 case Before:
57 list << "--delete-before";
58 break;
59 default:
60 break;
61 ;
62 }
63 }
64
65 if (skipNewer) {
66 list << "--update";
67 }
68 if (skipExisting) {
69 list << "--ignore-existing";
70 }
71
72 if (compare) {
73 switch (compareOption) {
74 case Checksum:
75 list << "--checksum";
76 break;
77 case IgnoreSize:
78 list << "--ignore-size";
79 break;
80 case SizeOnly:
81 list << "--size-only";
82 break;
83 case ChecksumIgnoreSize:
84 list << "--checksum"
85 << "--ignore-size";
86 break;
87 default:
88 break;
89 }
90 }
91
92 // always verbose
93 list << "--verbose";
94 if (sameFilesystem) {
95 list << "--one-file-system";
96 }
97 if (dontUpdateModified) {
98 list << "--no-update-modtime";
99 }
100
101 list << "--transfers" << transfers;
102 list << "--checkers" << checkers;
103
104 if (!bandwidth.isEmpty()) {
105 list << "--bwlimit" << bandwidth;
106 }
107 if (!minSize.isEmpty()) {
108 list << "--min-size" << minSize;
109 }
110 if (!minAge.isEmpty()) {
111 list << "--min-age" << minAge;
112 }
113 if (!maxAge.isEmpty()) {
114 list << "--max-age" << maxAge;
115 }
116
117 if (maxDepth != 0) {
118 list << "--max-depth" << QString::number(maxDepth);
119 }
120
121 list << "--contimeout" << (connectTimeout + "s");
122 list << "--timeout" << (idleTimeout + "s");
123 list << "--retries" << retries;
124 list << "--low-level-retries" << lowLevelRetries;
125
126 if (deleteExcluded) {
127 list << "--delete-excluded";
128 }
129
130 if (!excluded.isEmpty()) {
131 for (auto line : excluded.split('\n')) {
132 list << "--exclude" << line;
133 }
134 }
135
136 if (!extra.isEmpty()) {
137 for (auto arg : extra.split(' ')) {
138 list << arg;
139 }
140 }
141
142 if (DriveSharedWithMe) {
143 list << "--drive-shared-with-me";
144 }
145
146 list << "--stats"
147 << "1s";
148
149 list << "--stats-file-name-length"
150 << "0";
151
152 QStringList defaultRcloneOptionsList = GetDefaultRcloneOptionsList();
153 if (!defaultRcloneOptionsList.isEmpty()) {
154 list << defaultRcloneOptionsList;
155 }
156
157 list << source;
158 list << dest;
159
160 return list;
161 }
162
163 SerializationException::SerializationException(QString msg)
164 : QException(), Message(msg) {}