I often (i.e. 3 times out of 4) end up with the remote database being entirely deleted when using sync over a WebDAV connection. The Save function simply doesn't create anything. This isn't KeePass' fault as such, more likely down to the innumerable proxies and firewalls between me and the server.
Problem: In FileTransactionEx.cs function CommitWriteTransaction, it deletes an existing file if it exists. However, it doesn't check that the file it intends to rename exists. Suggest adding a simple test on line 99 which will at least leave the original file intact:
=======
if (!IOConnection.FileExists(m_iocTemp))
{
Debug.Assert(false);
return;
}
if\(IOConnection.FileExists\(m\_iocBase\)\)
\{
Second, it seems that a simple delay is enough to make the file write to the WebDAV provider correctly. I don't like this answer, but I also don't have time to properly fault-find :( The delay must come *before* the CommonCleanUpWrite call. Specifically, before the "hashedStream.Close()" call in CommonWriteCleanup; having it between here and the subsequent sSaveTo.Close() doesn't work.
In Kdb4File.Write.cs, function Save, suggest adding something more elegant than this to the "finally" clause:
========
finally {
if (saving to web) { System.Threading.Thread.Sleep(1000); }
CommonCleanUpWrite(sSaveTo, hashedStream);
}
========
Cheers,
Jim
This is a problem I run into a lot when running KeePass under Mono. The Mono WebDAV implementation seems to be a lot slower, so it's much less tolerant of race/sequencing errors.
I've implemented this patch naively and it seems to have the desired effect - if the temp file doesn't exist, sync/save fails with an error from a thrown exception (which I throw).
One thing I did notice was the first few runs I got some type of threading dead-lock when it ran. At a guess, the threading deadlock might be adding an arbitrary delay in save seems to help getting all the data to the WebDav server.
EDIT: The threading deadlock hasn't reoccurred in my time using this patch - I think it was an unrelated issue (Mono is touchy at times).
Last edit: Will R 2013-10-19
Keepass es una herramienta muy poderosa ya que almacena todas nuestras contraseñas y todas esas estan dependiendo de un archivo que guarda dichas contraseñas y si por algun motivo una persona olvida dicha contraseña perdera la informacion de las contraseñas ya almacenadas entonces pienso que es necesario crear un metodo de recuperacion de contraseña parecido a lo que hacemos cuadno se pierda la contraseña de una cuenta como de correo por ejemplo puede ser con el uso de una herramienta misma de keepass para hacerla mas segura o un algun dispositivo movil o alguna cuenta de nuestra confianza, de esta manera si olvidamos la contraseña principal que nos lleva a las demas contraseñas no se pierda tambien todas las demas.
KeePass does not have a recovery mode or "back door". You must remember your master password to be able to access your passwords.
cheers, Paul
An option for the temporary file existence test has been added, see
https://sourceforge.net/p/keepass/patches/102/
The timing problem must be fixed in the server or Mono; a delay in KeePass is not a stable solution.
Thanks and best regards,
Dominik