Skip to content

Commit

Permalink
Fix wrong deletion of hsdir when using --appDataDir
Browse files Browse the repository at this point in the history
There are circumstances where input via --appDataDir
will lead to the hiddenservice-directory to be deleted.
Successfully reproduced using

  --appDataDir=~/foo

Although the "~" does not get interpreted correctly on
my linux system, it does manage to throw off the
mechanics of sparing the hiddenservice-directory from
being deletd.
  • Loading branch information
freimair committed Mar 4, 2020
1 parent dbecc0a commit 0b7788a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions common/src/main/java/bisq/common/storage/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ public static void deleteDirectory(File file, @Nullable File exclude, boolean ig
File[] files = file.listFiles();
if (files != null)
for (File f : files) {
if (!excludeFileFound)
excludeFileFound = f.equals(exclude);
if (!f.equals(exclude))
boolean excludeFileFoundLocal = exclude != null ? f.getAbsolutePath().equals(exclude.getAbsolutePath()) : false;
excludeFileFound |= excludeFileFoundLocal;
if (!excludeFileFoundLocal)
deleteDirectory(f, exclude, ignoreLockedFiles);
}
}
// Finally delete main file/dir if exclude file was not found in directory
if (!excludeFileFound && !file.equals(exclude)) {
if (!excludeFileFound && !(exclude != null ? file.getAbsolutePath().equals(exclude.getAbsolutePath()) : false)) {
try {
deleteFileIfExists(file, ignoreLockedFiles);
} catch (Throwable t) {
Expand Down

0 comments on commit 0b7788a

Please sign in to comment.