Skip to content

Commit

Permalink
Add option to delete config files
Browse files Browse the repository at this point in the history
  • Loading branch information
nov1n committed Oct 5, 2024
1 parent 6934f44 commit 76965f8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ from https://docs.docker.com/get-docker/. Then run the following command to star
have not tested it on Windows yet):

```
touch ~/.remarkable-pocket ~/.rmapi && mkdir -p ~/.rmapi-cache && docker run -it --env TZ=Europe/Amsterdam -p 65112:65112 -v ~/.remarkable-pocket:/root/.remarkable-pocket -v ~/.rmapi:/root/.rmapi -v ~/.rmapi-cache:/root/.cache/rmapi ghcr.io/nov1n/remarkable-pocket:0.5.0
touch ~/.remarkable-pocket ~/.rmapi && mkdir -p ~/.rmapi-cache && docker run -it --env TZ=Europe/Amsterdam -p 65112:65112 -v ~/.remarkable-pocket:/root/.remarkable-pocket -v ~/.rmapi:/root/.rmapi -v ~/.rmapi-cache:/root/.cache/rmapi ghcr.io/nov1n/remarkable-pocket:0.6.0
```

The first time you run the application, you will be asked to authorize Pocket and Remarkable Cloud. Once you have done
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "nl.carosi"
version = "0.5.0"
version = "0.6.0"

java {
toolchain {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
remarkable-pocket:
image: ghcr.io/nov1n/remarkable-pocket:0.5.0
image: ghcr.io/nov1n/remarkable-pocket:0.6.0
restart: always
environment:
- TZ=Europe/Amsterdam
Expand Down
46 changes: 13 additions & 33 deletions src/main/java/nl/carosi/remarkablepocket/SyncCommand.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package nl.carosi.remarkablepocket;

import com.google.common.io.MoreFiles;
import com.google.common.io.RecursiveDeleteOption;
import org.springframework.boot.builder.SpringApplicationBuilder;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
Expand Down Expand Up @@ -96,7 +99,6 @@ class SyncCommand implements Callable<Integer> {
hidden = true)
private String authFile;

// TODO: Create composite logger
@Option(
names = {"-v", "--verbose"},
description = "Enable debug logging.",
Expand All @@ -116,43 +118,21 @@ public static void main(String... args) {
}

private static void resetConfiguration(List<String> configurationFiles) {
for (String path : configurationFiles) {
File file = new File(path);
if (file.exists()) {
if (file.isDirectory()) {
boolean deleted = deleteDirectory(file);
if (deleted) {
System.out.printf("Successfully deleted directory: %s\n", path);
} else {
System.out.printf("Failed to delete directory: %s\n", path);
}
} else {
boolean deleted = file.delete();
if (deleted) {
System.out.printf("Successfully deleted file: %s\n", path);
} else {
System.out.printf("Failed to delete file: %s\n", path);
}
for (String pathString : configurationFiles) {
Path path = Paths.get(pathString);
if (Files.exists(path)) {
try {
MoreFiles.deleteRecursively(path, RecursiveDeleteOption.ALLOW_INSECURE);
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.printf("Successfully deleted directory: %s%n", pathString);
} else {
System.out.printf("File or directory does not exist: %s, skipping...\n", path);
System.out.printf("File or directory does not exist: %s, skipping...%n", pathString);
}
}
}

private static boolean deleteDirectory(File directory) {
File[] files = directory.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
deleteDirectory(file);
}
file.delete();
}
}
return directory.delete();
}

private static Path getAppDataPath() {
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("win")) {
Expand Down

0 comments on commit 76965f8

Please sign in to comment.