private async Task <List <FileData> > EnumerateDownloadableFilesFromHashList(string path) { HashList = await SmartCopy.GetHashList(remote, true); List <FileData> workingList = HashList.Where(f => f.RelativePath.StartsWith(path)).ToList(); OnReportTotalFilesCount?.Invoke(workingList.Count); var retv = new List <FileData>(); foreach (var a in HashList) { string hash = ""; if (local.Exists(a.RelativePath)) { local.Read(a.RelativePath, async(stream) => { await Task.Yield(); hash = await GetHash(stream); }).Wait(); } var gzSuffix = ""; if (options.UseGZip) { gzSuffix = GZIP_FILE_SUFFIX; } while ((a.Hash != hash || !local.Exists(a.RelativePath))) { if (remote.Exists(a.RelativePath + gzSuffix)) { retv.Add(a); } } } return(retv); }
/// <summary> /// Copies files from local/origin accessor to remote/destination accessor /// Uploads data from the local to the remote accessor /// </summary> public async Task MirrorUp(string path = "") { if (remote == null) { throw new NullReferenceException("The Remote server was not specified, do call SetRemote(IFileAccessor) to specify it."); } var totalFilesCount = CountFiles(local, path); OnReportTotalFilesCount?.Invoke(totalFilesCount); await Mirror(local, remote, path, MirrorWay.Up); }
/// <summary> /// Copies files remote/destination from accessor to local/origin accessor /// Downloads data from the remote to the local accessor /// </summary> public async Task MirrorDown(string path = "") { if (remote == null) { throw new NullReferenceException("The Remote server was not specified, do call SetRemote(IFileAccessor) to specify it."); } if (options.UseHashList) { await MirrorFromList(path); } else { var totalFilesCount = CountFiles(remote, path); OnReportTotalFilesCount?.Invoke(totalFilesCount); await Mirror(remote, local, path, MirrorWay.Down); } }