File tree 4 files changed +52
-0
lines changed
4 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 48
48
49
49
parsers = {}
50
50
51
+ def warningOnTakeSnapshot (config ):
52
+ hasMissing , missing = snapshots .hasMissing (config .include ())
53
+ if hasMissing :
54
+ msgMissing = ', ' .join (missing )
55
+ msg = f'{ _ ("The following folders are missing" )} : { msgMissing } '
56
+ logger .warning (msg )
57
+ return True
58
+
51
59
def takeSnapshotAsync (cfg , checksum = False ):
52
60
"""
53
61
Fork a new backintime process with 'backup' command which will
@@ -56,6 +64,7 @@ def takeSnapshotAsync(cfg, checksum = False):
56
64
Args:
57
65
cfg (config.Config): config that should be used
58
66
"""
67
+ warningOnTakeSnapshot (cfg )
59
68
cmd = []
60
69
if cfg .ioniceOnUser ():
61
70
cmd .extend (('ionice' , '-c2' , '-n7' ))
@@ -94,6 +103,7 @@ def takeSnapshot(cfg, force = True):
94
103
Returns:
95
104
bool: ``True`` if there was an error
96
105
"""
106
+ warningOnTakeSnapshot (cfg )
97
107
tools .envLoad (cfg .cronEnvFile ())
98
108
ret = snapshots .Snapshots (cfg ).backup (force )
99
109
return ret
Original file line number Diff line number Diff line change @@ -1724,6 +1724,14 @@ msgstr "AVISO"
1724
1724
msgid "Exclude {path} from future snapshots?"
1725
1725
msgstr "Excluir {path} de snapshots futuros?"
1726
1726
1727
+ #: qt/app.py:1189
1728
+ msgid "The following folders are missing"
1729
+ msgstr "As seguintes pastas estão faltando"
1730
+
1731
+ #: qt/app.py:1189
1732
+ msgid "Do you want to proceed?"
1733
+ msgstr "Deseja prosseguir?"
1734
+
1727
1735
#~ msgid " and add your user to group 'fuse'"
1728
1736
#~ msgstr " e adicionar seu usuário para grupo 'fuse'"
1729
1737
Original file line number Diff line number Diff line change @@ -3104,6 +3104,25 @@ def lastSnapshot(cfg):
3104
3104
return sids [0 ]
3105
3105
3106
3106
3107
+ def hasMissing (included ):
3108
+ """
3109
+ Check if there are missing files or folders in a snapshot.
3110
+
3111
+ Args:
3112
+ included (list): list of tuples (item, info)
3113
+
3114
+ Returns:
3115
+ tuple: (bool, str) where bool is ``True`` if there are
3116
+ missing files or folders and str is a message
3117
+ describing the missing files or folders
3118
+ """
3119
+ notFound = []
3120
+ for path , info in included :
3121
+ if not os .path .exists (path ):
3122
+ notFound .append (path )
3123
+ return bool (notFound ), notFound
3124
+
3125
+
3107
3126
if __name__ == '__main__' :
3108
3127
config = config .Config ()
3109
3128
snapshots = Snapshots (config )
Original file line number Diff line number Diff line change @@ -1182,11 +1182,26 @@ def updateTimeLine(self, refreshSnapshotsList = True):
1182
1182
item = self .timeLine .addSnapshot (sid )
1183
1183
self .timeLine .checkSelection ()
1184
1184
1185
+ def validateOnTakeSnapshot (self ):
1186
+ hasMissing , missing = snapshots .hasMissing (self .config .include ())
1187
+ if hasMissing :
1188
+ msgMissing = '\n ' .join (missing )
1189
+ msg = f'{ _ ("The following folders are missing" )} :\n \n { msgMissing } \n \n { _ ("Do you want to proceed?" )} '
1190
+ answer = messagebox .warningYesNo (self , msg )
1191
+ return answer == QMessageBox .StandardButton .Yes
1192
+ return True
1193
+
1185
1194
def btnTakeSnapshotClicked (self ):
1195
+ proceed = self .validateOnTakeSnapshot ()
1196
+ if not proceed :
1197
+ return
1186
1198
backintime .takeSnapshotAsync (self .config )
1187
1199
self .updateTakeSnapshot (True )
1188
1200
1189
1201
def btnTakeSnapshotChecksumClicked (self ):
1202
+ proceed = self .validateOnTakeSnapshot ()
1203
+ if not proceed :
1204
+ return
1190
1205
backintime .takeSnapshotAsync (self .config , checksum = True )
1191
1206
self .updateTakeSnapshot (True )
1192
1207
You can’t perform that action at this time.
0 commit comments