In case the BSQ blocks directory does not exist in resources (as in case of REG_TEST)

we do not want to log an error stacktrace but just an info message.

Use `File.separator` instead of "/"
This commit is contained in:
chimp1984 2021-12-09 11:04:55 -05:00
parent f3d2cc38dc
commit d74bffb595
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3

View file

@ -22,6 +22,7 @@ import bisq.core.dao.state.model.blockchain.Block;
import bisq.common.config.Config;
import bisq.common.file.FileUtil;
import bisq.common.file.ResourceNotFoundException;
import bisq.common.proto.persistable.PersistenceProtoResolver;
import protobuf.BaseBlock;
@ -104,10 +105,9 @@ public class BsqBlocksStorageService {
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;
@ -123,9 +123,11 @@ public class BsqBlocksStorageService {
}
for (String fileName : fileNames) {
File destinationFile = new File(storageDir, fileName);
FileUtil.resourceToFile(resourceDir + "/" + fileName, destinationFile);
FileUtil.resourceToFile(resourceDir + File.separator + 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();
}