private async Task <StorageFile> GetUnCompressedDBFile() { try { StorageFile collectionFile; var compressedRemoteDB = await CreateTempFileAsync(Constant.COLLECTION_NAME_ZIP); await syncInstance.DownloadItemWithPathAsync(Constant.ANKIROOT_SYNC_FOLDER + "/" + Constant.COLLECTION_NAME_ZIP, compressedRemoteDB); using (var fileStream = await compressedRemoteDB.OpenStreamForReadAsync()) using (ZipArchive archive = new ZipArchive(fileStream, ZipArchiveMode.Read)) { archive.ExtractToDirectory(tempSyncFolder.Path); } collectionFile = await tempSyncFolder.TryGetItemAsync(Constant.COLLECTION_NAME) as StorageFile; return(collectionFile); } catch { return(null); } }
private async Task <StorageFile> GetUnCompressedDBFile() { StorageFile collectionFile; try { var compressedRemoteDB = await CreateTempFileAsync(Constant.COLLECTION_NAME_ZIP); await syncInstance.DownloadItemWithPathAsync(Constant.ANKIROOT_SYNC_FOLDER + "/" + Constant.COLLECTION_NAME_ZIP, compressedRemoteDB); using (var fileStream = await compressedRemoteDB.OpenStreamForReadAsync()) using (ZipArchive archive = new ZipArchive(fileStream, ZipArchiveMode.Read)) { archive.ExtractToDirectory(tempSyncFolder.Path); } collectionFile = await tempSyncFolder.TryGetItemAsync(Constant.COLLECTION_NAME) as StorageFile; } catch {// NO zipFile await UIHelper.ShowMessageDialog("Please update all your devices to the newest version and re-sync your data."); var oldSyncFile = await syncInstance.TryGetItemInRemotePathAsync(Constant.COLLECTION_NAME, Constant.ANKIROOT_SYNC_FOLDER); if (oldSyncFile != null) { await syncInstance.DeleteItemWithPathAsync(Constant.ANKI_COL_SYNC_PATH); } collectionFile = null; } return(collectionFile); }