private void SyncUpload(PwDatabase pwDatabase, SafeVaultWebClient webClient, string databaseUuid, SafeVaultConf vaultConf) { var lastModified = GetLastModified(pwDatabase); var location = _host.Database.IOConnectionInfo.Path; SetStatusText("Saving to SafeVault..."); Async.Invoke(() => { webClient.DbxUpload( databaseUuid, File.ReadAllBytes(location), lastModified); }); SetStatusText("Successfull Upload to SafeVault"); vaultConf.SyncRemoteLastModified = lastModified.ToString("u"); vaultConf.Save(); }
private void SyncRemote(PwDatabase pwDatabase, SafeVaultWebClient webClient, string databaseUuid, SafeVaultConf vaultConf) { SetStatusText("Check changes..."); var localLastModified = GetLastModified(pwDatabase); var lastModified = GetRemoteLastModified(webClient, databaseUuid); if (lastModified != null && lastModified == localLastModified) { SetStatusText("No changes."); return; } if (lastModified != null && lastModified.Value.ToString("u") != vaultConf.SyncRemoteLastModified) { SetStatusText("Downloading..."); var dbData = Async.Invoke(() => DownloadFile(webClient, databaseUuid, vaultConf)); if (dbData != null) { SetStatusText("Sync..."); SyncDatabase(pwDatabase, dbData, true); _host.MainWindow.Enabled = false; localLastModified = GetLastModified(pwDatabase); } } SetStatusText("Saving to SafeVault..."); Async.Invoke(() => { webClient.DbxUpload( databaseUuid, File.ReadAllBytes(pwDatabase.IOConnectionInfo.Path), localLastModified); }); SetStatusText("Successfull Sync Local <=> Remote"); vaultConf.SyncRemoteLastModified = localLastModified.ToString("u"); vaultConf.Save(); pwDatabase.Save(new NullStatusLogger()); }