Skip to content

Commit

Permalink
working on performing the encryption and backup in a separate thread …
Browse files Browse the repository at this point in the history
…with verification of the backup before rotating (#2148)
  • Loading branch information
giuspen committed Nov 22, 2022
1 parent f63142f commit f87c8ff
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/ct/ct_storage_control.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,25 +340,19 @@ void CtStorageControl::_backupEncryptThread()

// encrypt the file
if (pBackupEncryptData->needEncrypt) {
if (pBackupEncryptData->needBackup) {
// move the latest file version before the rotation
if (not fs::move_file(pBackupEncryptData->file_path, pBackupEncryptData->main_backup)) {
_pCtMainWin->errorsDEQueue.push_back(str::format(_("You Have No Write Access to %s"), fs::path{pBackupEncryptData->file_path}.parent_path().string()));
_pCtMainWin->dispatcherErrorMsg.emit();
continue;
}
}
const bool retValEncrypt = _package_file(pBackupEncryptData->extracted_copy, pBackupEncryptData->file_path, pBackupEncryptData->password);
if (not fs::remove(pBackupEncryptData->extracted_copy)) {
spdlog::debug("Failed to remove {}", pBackupEncryptData->extracted_copy);
}
if (not retValEncrypt) {
// move back the latest file version
(void)fs::move_file(pBackupEncryptData->main_backup, pBackupEncryptData->file_path);
spdlog::debug("{} -> {}", pBackupEncryptData->main_backup, pBackupEncryptData->file_path);
_pCtMainWin->errorsDEQueue.push_back(_("Failed to encrypt the file"));
_pCtMainWin->dispatcherErrorMsg.emit();
continue;
}
spdlog::debug("{} => {}", pBackupEncryptData->extracted_copy, pBackupEncryptData->file_path);
}

if (not pBackupEncryptData->needBackup) {
Expand Down

0 comments on commit f87c8ff

Please sign in to comment.