Wallet: use getAbsoluteFile() when checking if parent directory exists

This fixes a NPE when using wallet-tool to create a new wallet on a path
without directory, e.g. `wallet-tool create --wallet=test.wallet`.
This commit is contained in:
Sean Gilligan 2023-09-07 08:41:37 -07:00 committed by Andreas Schildbach
parent 8aa808f7d4
commit 110da96911

View file

@ -1700,11 +1700,11 @@ public class Wallet extends BaseTaggableObject
* @throws IOException if an error occurs while saving
*/
public void saveToFile(File tempFile, File destFile) throws IOException {
File tempParentFile = tempFile.getParentFile();
File tempParentFile = tempFile.getAbsoluteFile().getParentFile();
if (!tempParentFile.exists()) {
throw new FileNotFoundException(tempParentFile.getPath() + " (wallet directory not found)");
}
File destParentFile = destFile.getParentFile();
File destParentFile = destFile.getAbsoluteFile().getParentFile();
if (!destParentFile.exists()) {
throw new FileNotFoundException(destParentFile.getPath() + " (wallet directory not found)");
}