private void downloadVerseDatabase(DropNetClient client) { const string VerseDbFileName = "verses.sqlite3"; client.GetMetaDataAsync("/", metadata => { var versesDb = metadata.Contents .Where(x => !x.Is_Dir && x.Name == VerseDbFileName) .FirstOrDefault(); if (versesDb == null) { notifyError("Could not find '" + VerseDbFileName + "' in your Dropbox root folder."); return; } client.GetFileAsync(versesDb.Path, file => { var fileBytes = file.RawBytes; var fileStream = new MemoryStream(fileBytes); writeDatabaseToIsolatedStorage(fileStream); }, ex => notifyError(ex)); }, ex => notifyError(ex)); }
private static void OnFileMetaReady( DropNetClient client, SyncInfo info, MetaData meta, Action<SyncCompleteInfo> report) { // No change from server side if (meta.Modified == info.Modified) { if (!info.HasLocalChanges) { report(new SyncCompleteInfo { Path = info.Path, Result = SyncResults.NoChange, }); return; } // Has local change, upload to server client.UploadFileAsync(info.Path, info.Database, x => report(new SyncCompleteInfo { Path = info.Path, Modified = x.Modified, Result = SyncResults.Uploaded, }), x => report(new SyncCompleteInfo { Path = info.Path, Result = SyncResults.Failed, })); return; } // Has changes from server if (!info.HasLocalChanges) { // Database should be updated client.GetFileAsync(info.Path, x => report(new SyncCompleteInfo { Path = info.Path, Database = x.RawBytes, Modified = meta.Modified, Result = SyncResults.Downloaded, }), ex => report(new SyncCompleteInfo { Path = info.Path, Result = SyncResults.Failed, })); return; } // Conflict var path = GetNonConflictPath(info.Path); client.UploadFileAsync(path, info.Database, x => report(new SyncCompleteInfo { Modified = x.Modified, Path = client.GetUrl(path), Result = SyncResults.Conflict, }), x => report(new SyncCompleteInfo { Path = info.Path, Result = SyncResults.Failed, })); }