Skip to content

Commit

Permalink
add exception to trigger the fail
Browse files Browse the repository at this point in the history
  • Loading branch information
jckleiner committed Dec 23, 2023
1 parent f9cc255 commit eaf5071
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/main/java/com/greydev/notionbackup/NotionBackup.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
}


Expand All @@ -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<String> getDropboxAccessToken() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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<String> extractGoogleServiceAccountSecret() {
Expand Down

0 comments on commit eaf5071

Please sign in to comment.