mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix database creation issue
This commit is contained in:
@@ -215,6 +215,8 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void saveData(Context ctx, Uri uri) throws IOException, PwDbOutputException {
|
private void saveData(Context ctx, Uri uri) throws IOException, PwDbOutputException {
|
||||||
|
String errorMessage = "Failed to store database.";
|
||||||
|
|
||||||
if (uri.getScheme().equals("file")) {
|
if (uri.getScheme().equals("file")) {
|
||||||
String filename = uri.getPath();
|
String filename = uri.getPath();
|
||||||
File tempFile = new File(filename + ".tmp");
|
File tempFile = new File(filename + ".tmp");
|
||||||
@@ -226,7 +228,8 @@ public class Database {
|
|||||||
if (pmo != null)
|
if (pmo != null)
|
||||||
pmo.output();
|
pmo.output();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IOException("Failed to store database.");
|
Log.e(TAG, errorMessage, e);
|
||||||
|
throw new IOException(errorMessage, e);
|
||||||
} finally {
|
} finally {
|
||||||
if (fos != null)
|
if (fos != null)
|
||||||
fos.close();
|
fos.close();
|
||||||
@@ -242,7 +245,7 @@ public class Database {
|
|||||||
File orig = new File(filename);
|
File orig = new File(filename);
|
||||||
|
|
||||||
if (!tempFile.renameTo(orig)) {
|
if (!tempFile.renameTo(orig)) {
|
||||||
throw new IOException("Failed to store database.");
|
throw new IOException(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -253,7 +256,8 @@ public class Database {
|
|||||||
if (pmo != null)
|
if (pmo != null)
|
||||||
pmo.output();
|
pmo.output();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IOException("Failed to store database.");
|
Log.e(TAG, errorMessage, e);
|
||||||
|
throw new IOException(errorMessage, e);
|
||||||
} finally {
|
} finally {
|
||||||
if (os != null)
|
if (os != null)
|
||||||
os.close();
|
os.close();
|
||||||
|
|||||||
@@ -293,6 +293,9 @@ public class PwDbV4Output extends PwDbOutput<PwDbHeaderV4> {
|
|||||||
}
|
}
|
||||||
random.nextBytes(header.encryptionIV);
|
random.nextBytes(header.encryptionIV);
|
||||||
|
|
||||||
|
if (mPM.getKdfParameters() == null) {
|
||||||
|
mPM.setKdfParameters(KdfFactory.aesKdf.getDefaultParameters());
|
||||||
|
}
|
||||||
KdfEngine kdf = KdfFactory.get(mPM.getKdfParameters());
|
KdfEngine kdf = KdfFactory.get(mPM.getKdfParameters());
|
||||||
kdf.randomize(mPM.getKdfParameters());
|
kdf.randomize(mPM.getKdfParameters());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user