-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow deleting left-over files after restore completed (#107)
- Adds new command line flag --delete-missing - Collects and deletes left-over files during RestoreController execution - Adds/updates tests - Updates documentation Resolves #106 {minor} Signed-off-by: Esta Nagy <[email protected]>
- Loading branch information
Showing
15 changed files
with
280 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
file-barj-core/src/main/java/com/github/nagyesta/filebarj/core/config/RestoreTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.github.nagyesta.filebarj.core.config; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NonNull; | ||
|
||
/** | ||
* Defines the parameters of a restore task. | ||
*/ | ||
@Data | ||
@Builder | ||
public class RestoreTask { | ||
|
||
/** | ||
* Defines the target directories to restore files to. | ||
*/ | ||
@NonNull | ||
private final RestoreTargets restoreTargets; | ||
/** | ||
* The number of threads to use for parallel restore. | ||
*/ | ||
private final int threads; | ||
/** | ||
* Disallows file system changes when true. | ||
*/ | ||
private final boolean dryRun; | ||
/** | ||
* Allows deleting files from the restore targets which would have been in the backup scope but | ||
* are not in the backup increment when true. | ||
*/ | ||
private final boolean deleteFilesNotInBackup; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
file-barj-core/src/test/java/com/github/nagyesta/filebarj/core/config/RestoreTaskTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.github.nagyesta.filebarj.core.config; | ||
|
||
import com.github.nagyesta.filebarj.core.TempFileAwareTest; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Set; | ||
|
||
class RestoreTaskTest extends TempFileAwareTest { | ||
|
||
@SuppressWarnings("DataFlowIssue") | ||
@Test | ||
void testBuilderShouldThrowExceptionWhenCalledWithNullRestoreTargets() { | ||
//given | ||
|
||
//when | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> RestoreTask.builder() | ||
.restoreTargets(null)); | ||
|
||
//then + exception | ||
} | ||
|
||
@Test | ||
void testBuilderShouldCreateInstanceWhenCalledWithValidData() { | ||
//given | ||
final var dryRun = true; | ||
final var threads = 2; | ||
final var deleteFilesNotInBackup = true; | ||
final var restoreTargets = new RestoreTargets(Set.of(new RestoreTarget(Path.of("source"), Path.of("target")))); | ||
|
||
//when | ||
final var actual = RestoreTask.builder() | ||
.restoreTargets(restoreTargets) | ||
.dryRun(dryRun) | ||
.threads(threads) | ||
.deleteFilesNotInBackup(deleteFilesNotInBackup) | ||
.build(); | ||
|
||
//then | ||
Assertions.assertEquals(dryRun, actual.isDryRun()); | ||
Assertions.assertEquals(threads, actual.getThreads()); | ||
Assertions.assertEquals(deleteFilesNotInBackup, actual.isDeleteFilesNotInBackup()); | ||
Assertions.assertEquals(restoreTargets, actual.getRestoreTargets()); | ||
} | ||
} |
Oops, something went wrong.