Implemented UI for sync

Fixed bugs
This commit is contained in:
Philipp Crocoll
2013-07-11 17:27:10 +02:00
parent 16c08cbe8a
commit deeaa673a5
14 changed files with 630 additions and 548 deletions

View File

@@ -27,10 +27,16 @@ namespace keepass2android.Io
{
if (!ioc.IsLocalFile())
return false;
DateTime previousDate;
if (!DateTime.TryParse(previousFileVersion, out previousDate))
if (previousFileVersion == null)
return false;
return File.GetLastWriteTimeUtc(ioc.Path) > previousDate;
DateTime previousDate;
if (!DateTime.TryParse(previousFileVersion, CultureInfo.InvariantCulture, DateTimeStyles.None, out previousDate))
return false;
DateTime currentModificationDate = File.GetLastWriteTimeUtc(ioc.Path);
TimeSpan diff = currentModificationDate - previousDate;
return diff > TimeSpan.FromSeconds(1);
//don't use > operator because milliseconds are truncated
return File.GetLastWriteTimeUtc(ioc.Path) - previousDate >= TimeSpan.FromSeconds(1);
}

View File

@@ -43,6 +43,7 @@ namespace keepass2android.Io
/// </summary>
/// Note: This function may return false even if the file might have changed. The function
/// should focus on being fast and cheap instead of doing things like hashing or downloading a full file.
/// previousFileVersion may be null to indicate no previous version is known.
/// <returns>Returns true if a change was detected, false otherwise.</returns>
bool CheckForFileChangeFast(IOConnectionInfo ioc , string previousFileVersion);