MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / MoveOldDataFiles

Function MoveOldDataFiles

Telegram/SourceFiles/logs.cpp:291–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289bool DebugModeEnabled = false;
290
291[[maybe_unused]] void MoveOldDataFiles(const QString &wasDir) {
292 if (wasDir.isEmpty()) {
293 return;
294 }
295 QFile data(wasDir + "data"), dataConfig(wasDir + "data_config"), tdataConfig(wasDir + "tdata/config");
296 if (data.exists() && dataConfig.exists() && !QFileInfo::exists(cWorkingDir() + "data") && !QFileInfo::exists(cWorkingDir() + "data_config")) { // move to home dir
297 LOG(("Copying data to home dir '%1' from '%2'").arg(cWorkingDir(), wasDir));
298 if (data.copy(cWorkingDir() + "data")) {
299 LOG(("Copied 'data' to home dir"));
300 if (dataConfig.copy(cWorkingDir() + "data_config")) {
301 LOG(("Copied 'data_config' to home dir"));
302 bool tdataGood = true;
303 if (tdataConfig.exists()) {
304 tdataGood = false;
305 QDir().mkpath(cWorkingDir() + "tdata");
306 if (tdataConfig.copy(cWorkingDir() + "tdata/config")) {
307 LOG(("Copied 'tdata/config' to home dir"));
308 tdataGood = true;
309 } else {
310 LOG(("Copied 'data' and 'data_config', but could not copy 'tdata/config'!"));
311 }
312 }
313 if (tdataGood) {
314 if (data.remove()) {
315 LOG(("Removed 'data'"));
316 } else {
317 LOG(("Could not remove 'data'"));
318 }
319 if (dataConfig.remove()) {
320 LOG(("Removed 'data_config'"));
321 } else {
322 LOG(("Could not remove 'data_config'"));
323 }
324 if (!tdataConfig.exists() || tdataConfig.remove()) {
325 LOG(("Removed 'tdata/config'"));
326 } else {
327 LOG(("Could not remove 'tdata/config'"));
328 }
329 QDir().rmdir(wasDir + "tdata");
330 }
331 } else {
332 LOG(("Copied 'data', but could not copy 'data_config'!!"));
333 }
334 } else {
335 LOG(("Could not copy 'data'!"));
336 }
337 }
338}
339
340} // namespace
341

Callers 1

startFunction · 0.85

Calls 2

isEmptyMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected