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() {