From eaf507141d3169d2864161349f2d0420992bf798 Mon Sep 17 00:00:00 2001 From: jckleiner Date: Sat, 23 Dec 2023 23:58:48 +0100 Subject: [PATCH] add exception to trigger the fail --- .../greydev/notionbackup/NotionBackup.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/greydev/notionbackup/NotionBackup.java b/src/main/java/com/greydev/notionbackup/NotionBackup.java index a5593b9..842f105 100644 --- a/src/main/java/com/greydev/notionbackup/NotionBackup.java +++ b/src/main/java/com/greydev/notionbackup/NotionBackup.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.rmi.UnexpectedException; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicBoolean; @@ -123,7 +124,11 @@ public static void startGoogleDriveBackup(File fileToUpload) { return; } GoogleDriveClient GoogleDriveClient = new GoogleDriveClient(googleServiceOptional.get(), googleDriveRootFolderId); - GoogleDriveClient.upload(fileToUpload); + boolean isSuccess = GoogleDriveClient.upload(fileToUpload); + + if (!isSuccess) { + throw new IllegalStateException("Backup was not successful"); + } } @@ -140,7 +145,11 @@ public static void startDropboxBackup(File fileToUpload) { return; } DropboxClient dropboxClient = new DropboxClient(dropboxServiceOptional.get()); - dropboxClient.upload(fileToUpload); + boolean isSuccess = dropboxClient.upload(fileToUpload); + + if (!isSuccess) { + throw new IllegalStateException("Backup was not successful"); + } } private static Optional getDropboxAccessToken() { @@ -184,7 +193,11 @@ public static void startNextcloudBackup(File fileToUpload) { return; } - new NextcloudClient(email, password, webdavUrl).upload(fileToUpload); + boolean isSuccess = new NextcloudClient(email, password, webdavUrl).upload(fileToUpload); + + if (!isSuccess) { + throw new IllegalStateException("Backup was not successful"); + } } public static void startPCloudBackup(File fileToUpload) { @@ -213,7 +226,11 @@ public static void startPCloudBackup(File fileToUpload) { } } PCloudClient pCloudClient = new PCloudClient(pCloudApiClient.get(), pCloudFolderId); - pCloudClient.upload(fileToUpload); + boolean isSuccess = pCloudClient.upload(fileToUpload); + + if (!isSuccess) { + throw new IllegalStateException("Backup was not successful"); + } } private static Optional extractGoogleServiceAccountSecret() {