diff --git a/CHANGES b/CHANGES index b49573925..6e53decac 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ Back In Time Version 1.4.4-dev (development of upcoming release) +* Fix bug: Check if Include folders/files do exists (in case they are removed) (1586) (@rafaelhdr) * Feature: Support SSH proxy (jump) host (#1688) (@cgrinham, Christie Grinham) * Removed: Context menu in LogViewDialog (#1578) * Refactor: Replace Config.user() with getpass.getuser() (#1694) diff --git a/common/backintime.py b/common/backintime.py index bd21b07b9..e6214a91f 100644 --- a/common/backintime.py +++ b/common/backintime.py @@ -48,6 +48,14 @@ parsers = {} +def warningOnTakeSnapshot(config): + hasMissing, missing = snapshots.hasMissing(config.include()) + if hasMissing: + msgMissing = ', '.join(missing) + msg = f'{_("The following folders are missing")}: {msgMissing}' + logger.warning(msg) + return True + def takeSnapshotAsync(cfg, checksum = False): """ Fork a new backintime process with 'backup' command which will @@ -56,6 +64,7 @@ def takeSnapshotAsync(cfg, checksum = False): Args: cfg (config.Config): config that should be used """ + warningOnTakeSnapshot(cfg) cmd = [] if cfg.ioniceOnUser(): cmd.extend(('ionice', '-c2', '-n7')) @@ -94,6 +103,7 @@ def takeSnapshot(cfg, force = True): Returns: bool: ``True`` if there was an error """ + warningOnTakeSnapshot(cfg) tools.envLoad(cfg.cronEnvFile()) ret = snapshots.Snapshots(cfg).backup(force) return ret diff --git a/common/po/pt_BR.po b/common/po/pt_BR.po index 707873a03..4c483ed55 100644 --- a/common/po/pt_BR.po +++ b/common/po/pt_BR.po @@ -1724,6 +1724,14 @@ msgstr "AVISO" msgid "Exclude {path} from future snapshots?" msgstr "Excluir {path} de snapshots futuros?" +#: qt/app.py:1189 +msgid "The following folders are missing" +msgstr "As seguintes pastas estão faltando" + +#: qt/app.py:1189 +msgid "Do you want to proceed?" +msgstr "Deseja prosseguir?" + #~ msgid " and add your user to group 'fuse'" #~ msgstr " e adicionar seu usuário para grupo 'fuse'" diff --git a/common/snapshots.py b/common/snapshots.py index 60d71c831..aab784980 100644 --- a/common/snapshots.py +++ b/common/snapshots.py @@ -3104,6 +3104,25 @@ def lastSnapshot(cfg): return sids[0] +def hasMissing(included): + """ + Check if there are missing files or folders in a snapshot. + + Args: + included (list): list of tuples (item, info) + + Returns: + tuple: (bool, str) where bool is ``True`` if there are + missing files or folders and str is a message + describing the missing files or folders + """ + notFound = [] + for path, info in included: + if not os.path.exists(path): + notFound.append(path) + return bool(notFound), notFound + + if __name__ == '__main__': config = config.Config() snapshots = Snapshots(config) diff --git a/qt/app.py b/qt/app.py index 07a3831d8..70a55dd9f 100644 --- a/qt/app.py +++ b/qt/app.py @@ -1182,11 +1182,26 @@ def updateTimeLine(self, refreshSnapshotsList = True): item = self.timeLine.addSnapshot(sid) self.timeLine.checkSelection() + def validateOnTakeSnapshot(self): + hasMissing, missing = snapshots.hasMissing(self.config.include()) + if hasMissing: + msgMissing = '\n'.join(missing) + msg = f'{_("The following folders are missing")}:\n\n{msgMissing}\n\n{_("Do you want to proceed?")}' + answer = messagebox.warningYesNo(self, msg) + return answer == QMessageBox.StandardButton.Yes + return True + def btnTakeSnapshotClicked(self): + proceed = self.validateOnTakeSnapshot() + if not proceed: + return backintime.takeSnapshotAsync(self.config) self.updateTakeSnapshot(True) def btnTakeSnapshotChecksumClicked(self): + proceed = self.validateOnTakeSnapshot() + if not proceed: + return backintime.takeSnapshotAsync(self.config, checksum = True) self.updateTakeSnapshot(True)