Skip to content

Commit

Permalink
Merge pull request #16 from KastenKlicker/multiple-upload-client
Browse files Browse the repository at this point in the history
Implement the possibility to upload to multiple servers.
  • Loading branch information
KastenKlicker authored Oct 12, 2024
2 parents 12dde3b + 71563f2 commit 912113d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Backup {
private final List<String> excludeFiles;
private final File backupDirectory;
private final File serverDirectory;
private final UploadClient uploadClient;
private final List<UploadClient> uploadClients;
private final long maxBackupDirectorySize;

/**
Expand All @@ -33,15 +33,15 @@ public class Backup {
* @param excludeFiles files which should be excluded from the backup
* @param backupDirectory the directory of the backups
* @param serverDirectory the directory which contains all server files
* @param uploadClient the specific class of the Upload protocol
* @param uploadClients Array of UploadClients
* @param maxBackupDirectorySize the maximum size of the backup directory
*/
public Backup(List<String> includedFiles, List<String> excludeFiles, File backupDirectory, File serverDirectory, UploadClient uploadClient, long maxBackupDirectorySize) {
public Backup(List<String> includedFiles, List<String> excludeFiles, File backupDirectory, File serverDirectory, List<UploadClient> uploadClients, long maxBackupDirectorySize) {
this.includedFiles = includedFiles;
this.excludeFiles = excludeFiles;
this.backupDirectory = backupDirectory;
this.serverDirectory = serverDirectory;
this.uploadClient = uploadClient;
this.uploadClients = uploadClients;
this.maxBackupDirectorySize = maxBackupDirectorySize;
}

Expand Down Expand Up @@ -73,7 +73,8 @@ public File backup() {

try {
// Upload file
uploadClient.upload(backupFile);
for (UploadClient uploadClient : uploadClients)
uploadClient.upload(backupFile);
} catch (Exception e) {
throw new UploadException(e);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.kastenklicker.secureserverbackuplibrary;

import de.kastenklicker.secureserverbackuplibrary.upload.NullUploadClient;
import de.kastenklicker.secureserverbackuplibrary.upload.SFTPClient;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -39,7 +38,7 @@ public void testBackup() {
new ArrayList<>(),
backupsDirectory,
new File("./src/test/resources/zipTest"),
new NullUploadClient(),
new ArrayList<>(),
1)
.backup().exists());
}
Expand Down Expand Up @@ -79,7 +78,7 @@ public void testBackupSFTP() throws Exception {
new ArrayList<>(),
backupsDirectory,
new File("./src/test/resources/zipTest"),
uploadClient,
List.of(uploadClient),
1)
.backup();

Expand Down Expand Up @@ -117,7 +116,7 @@ public void testBackupMaxDirSizeReached() throws Exception {
new ArrayList<>(),
backupsDirectory,
new File("./src/test/resources/zipTest"),
new NullUploadClient(),
new ArrayList<>(),
1)
.backup().exists());

Expand Down

0 comments on commit 912113d

Please sign in to comment.