@@ -187,13 +187,32 @@ public void initiatorError(String input, String... placeholders) {
187187 */
188188 @ Override
189189 public void run () {
190- Config config = ConfigParser .getConfig ();
191190 if (initiator != null && backupStatus != BackupStatus .NOT_RUNNING ) {
192191 logger .initiatorError (
193- intl ("backup-already-running" ),
192+ intl ("backup-already-running" ),
194193 "backup-status" , getBackupStatus ());
195194 return ;
196195 }
196+ try {
197+ run_internal ();
198+ } catch (Exception e ) {
199+ lastBackupSuccessful = false ;
200+ throw e ;
201+ } finally {
202+ backupStatus = BackupStatus .NOT_RUNNING ;
203+ if (lastBackupSuccessful ) {
204+ DriveBackupApi .backupDone ();
205+ } else {
206+ DriveBackupApi .backupError ();
207+ }
208+ }
209+ }
210+
211+ /**
212+ * actual backup logic
213+ */
214+ void run_internal () {
215+ Config config = ConfigParser .getConfig ();
197216 totalTimer .start ();
198217 backupStatus = BackupStatus .STARTING ;
199218 if (!locationsToBePruned .isEmpty ()) {
@@ -302,12 +321,6 @@ public void run() {
302321 long totalBackupTime = totalTimer .getTime ();
303322 long totalSeconds = Duration .of (totalBackupTime , ChronoUnit .MILLIS ).getSeconds ();
304323 logger .log (intl ("backup-total-time" ), "time" , String .valueOf (totalSeconds ));
305- backupStatus = BackupStatus .NOT_RUNNING ;
306- if (errorOccurred ) {
307- DriveBackupApi .backupError ();
308- } else {
309- DriveBackupApi .backupDone ();
310- }
311324 }
312325
313326 private void ensureMethodsAuthenticated () {
0 commit comments