3
0
mirror of https://github.com/Qortal/qortal.git synced 2025-02-13 02:35:50 +00:00

Ensure parent directories exist when creating a diff.

This commit is contained in:
CalDescent 2021-08-14 16:55:19 +01:00
parent 179318f1d8
commit d9f5753f58

View File

@ -127,6 +127,7 @@ public class ArbitraryDataDiff {
}); });
} catch (IOException e) { } catch (IOException e) {
// TODO: throw exception?
LOGGER.info("IOException when walking through file tree: {}", e.getMessage()); LOGGER.info("IOException when walking through file tree: {}", e.getMessage());
} }
} }
@ -202,7 +203,14 @@ public class ArbitraryDataDiff {
throw new IOException(String.format("File not found: %s", source.toString())); throw new IOException(String.format("File not found: %s", source.toString()));
} }
// Ensure parent folders exist in the destination
Path dest = Paths.get(base.toString(), relativePath.toString()); Path dest = Paths.get(base.toString(), relativePath.toString());
File file = new File(dest.toString());
File parent = file.getParentFile();
if (parent != null) {
parent.mkdirs();
}
LOGGER.trace("Copying {} to {}", source, dest); LOGGER.trace("Copying {} to {}", source, dest);
Files.copy(source, dest, StandardCopyOption.REPLACE_EXISTING); Files.copy(source, dest, StandardCopyOption.REPLACE_EXISTING);
} }