private void SyncUpload(PwDatabase pwDatabase, YandexWebDavClient webClient, string databaseUuid, YandexDiscSyncConf storageConf) { var lastModified = GetLastModified(pwDatabase); var location = _host.Database.IOConnectionInfo.Path; SetStatusText("Saving to Yandex Disc..."); Async.Invoke(() => { webClient.PutFile( databaseUuid, File.ReadAllBytes(location), lastModified, progress => { SetStatusText($"Saving to YandexDisc ({Math.Floor(progress)}%)"); }); }); SetStatusText("Successfull save to YandexDisc"); storageConf.SyncRemoteLastModified = lastModified.ToString("u"); storageConf.Save(); }
private void SyncRemote(PwDatabase pwDatabase, YandexWebDavClient webClient, string filename, YandexDiscSyncConf vaultConf) { SetStatusText("Check changes..."); var localLastModified = GetLastModified(pwDatabase); var lastModified = GetRemoteLastModified(filename, webClient); if (lastModified != null && lastModified == localLastModified) { SetStatusText("No changes."); return; } if (lastModified != null) { SetStatusText("Downloading..."); var dbData = Async.Invoke(() => DownloadFile(filename, webClient)); if (dbData != null) { SetStatusText("Sync..."); SyncDatabase(pwDatabase, dbData, true); _host.MainWindow.Enabled = false; localLastModified = GetLastModified(pwDatabase); } } SetStatusText("Saving to YandexDisc..."); Async.Invoke(() => { webClient.PutFile( filename, File.ReadAllBytes(pwDatabase.IOConnectionInfo.Path), localLastModified, progress => { SetStatusText($"Saving to YandexDisc ({Math.Floor(progress)}%)"); }); }); SetStatusText("Successfull Sync Local <=> Remote"); vaultConf.SyncRemoteLastModified = localLastModified.ToString("u"); vaultConf.Save(); pwDatabase.Save(new NullStatusLogger()); }