Skip to content

Commit

Permalink
Merge pull request #5909 from chimp1984/avoid-logging-error-for-non-e…
Browse files Browse the repository at this point in the history
…xisting-resource-files

Dont log error if BSQ blocks directory does not exist in resources
  • Loading branch information
ripcurlx committed Dec 9, 2021
2 parents f3d2cc3 + 225b783 commit 7a6ae2b
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import bisq.common.config.Config;
import bisq.common.file.FileUtil;
import bisq.common.file.ResourceNotFoundException;
import bisq.common.proto.persistable.PersistenceProtoResolver;

import protobuf.BaseBlock;
Expand Down Expand Up @@ -104,10 +105,9 @@ public LinkedList<Block> migrateBlocks(List<protobuf.BaseBlock> protobufBlocks)

void copyFromResources(String postFix) {
long ts = System.currentTimeMillis();
String dirName = BsqBlocksStorageService.NAME;
String resourceDir = dirName + postFix;
try {
String dirName = BsqBlocksStorageService.NAME;
String resourceDir = dirName + postFix;

if (storageDir.exists()) {
log.info("No resource directory was copied. {} exists already.", dirName);
return;
Expand All @@ -123,9 +123,13 @@ void copyFromResources(String postFix) {
}
for (String fileName : fileNames) {
File destinationFile = new File(storageDir, fileName);
// File.separator doesn't appear to work on Windows. It has to be "/", not "\".
// See: https://github.com/bisq-network/bisq/pull/5909#pullrequestreview-827992563
FileUtil.resourceToFile(resourceDir + "/" + fileName, destinationFile);
}
log.info("Copying {} resource files took {} ms", fileNames.size(), System.currentTimeMillis() - ts);
} catch (ResourceNotFoundException ignore) {
log.info("Directory {} in resources does not exist.", resourceDir);
} catch (Throwable e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 7a6ae2b

Please sign in to comment.