This commit is contained in:
AlexVallat 2013-07-13 11:57:53 +01:00
commit d71a204b2c
6 changed files with 96 additions and 5 deletions

View File

@ -663,7 +663,7 @@ namespace KeePassLib
Debug.Assert(ValidateUuidUniqueness());
Stream s = streamOfOriginalLocation;
KdbxFile kdb = new KdbxFile(this);
kdb.Save(s, null, KdbxFormat.Default, slLogger);
kdb.Save(s, null, KdbpFile.GetFormatToUse(m_ioSource), slLogger);
m_pbHashOfLastIO = kdb.HashOfFileOnDisk;
m_pbHashOfFileOnDisk = kdb.HashOfFileOnDisk;

View File

@ -136,12 +136,24 @@ namespace keepass2android
{
try
{
_workerThread = new Thread(runHandler);
_workerThread = new Thread(() =>
{
try
{
runHandler();
}
catch (Exception e)
{
Kp2aLog.Log("Error in worker thread of SaveDb: " + e);
Finish(false, e.Message);
}
});
_workerThread.Start();
}
catch (Exception e)
{
Kp2aLog.Log("Error in worker thread of SaveDb: "+e);
Kp2aLog.Log("Error starting worker thread of SaveDb: "+e);
Finish(false, e.Message);
}

View File

@ -91,5 +91,11 @@ namespace Kp2aUnitTests
}
[TestMethod]
public void TestLoadKdbpWithPasswordOnly()
{
RunLoadTest("passwordonly.kdbp", DefaultPassword, "");
}
}
}

View File

@ -263,6 +263,48 @@ namespace Kp2aUnitTests
}
[TestMethod]
public void TestLoadKdbxAndSaveKdbp_TestIdenticalFiles()
{
IKp2aApp app = LoadDatabase(DefaultDirectory + "complexDb.kdbx", "test", null);
//string kdbxXml = DatabaseToXml(app);
newFilename = TestDbDirectory + "tmp_complexDb.kdbp";
if (File.Exists(newFilename))
File.Delete(newFilename);
app.GetDb().KpDatabase.IOConnectionInfo.Path = newFilename;
app.GetDb().SaveData(Application.Context);
IKp2aApp appReloaded = LoadDatabase(newFilename, "test", null);
/*
* Unfortunately we cannot compare the xml because there are slight differences:
* - the order of ProtectedStrings in the xml is different (which is ok)
* - the CustomIconUuids are serialized as Zeros instead of not being serialized (which is ok as well)
string kdbxReloadedXml = DatabaseToXml(appReloaded);
bool areEqual = kdbxXml.Equals(kdbxReloadedXml);
if (!areEqual)
{
using (StreamWriter w1 = File.CreateText(TestDbDirectory + "FromOriginalKdbx.xml"))
{
w1.Write(kdbxXml);
}
using (StreamWriter w2 = File.CreateText(TestDbDirectory + "FromKdbp.xml"))
{
w2.Write(kdbxReloadedXml);
}
}
Assert.IsTrue(areEqual, "reloaded->xml differs from loaded->xml");
*/
AssertDatabasesAreEqual(app.GetDb().KpDatabase, appReloaded.GetDb().KpDatabase);
}
private class OnCloseToStringMemoryStream : MemoryStream

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="15"
android:versionName="0.8.4 preview"
android:versionCode="16"
android:versionName="0.8.4 preview 2"
package="keepass2android.keepass2android"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14" />

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="text"
android:hint="@string/field_name" />
<EditText
android:id="@+id/value"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:inputType="textMultiLine"
android:hint="@string/field_value"/>
<CheckBox
android:id="@+id/protection"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/value"
android:text="@string/protection"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/protection"
android:text="@string/delete_extra_string"
android:id="@+id/delete_extra" />
</RelativeLayout>