private RemoteVsLocalFile RemVsLoc(SyncableFileLocal locFile, SyncableFileRemote remNode, SyncDirection syncDirection) { //return new RemoteVsLocalFile(locFile?.Name ?? remNode.Name) //{ // Local = locFile, // Remote = RemoteFileInfo(remNode) //}; var fName = locFile?.Name ?? remNode.Name; var remFile = RemoteFileInfo(remNode); return(new RemoteVsLocalFile(fName, remFile, locFile, syncDirection)); }
public void Result_Same() { var rem = new SyncableFileRemote(); var loc = new SyncableFileLocal(); loc.Size = rem.Size = 123; loc.Version = rem.Version = "v.456"; loc.SHA1 = rem.SHA1 = "abc-def-ghi"; var sut = new RemoteVsLocalFile("file.txt", rem, loc, SyncDirection.Upload); sut.Comparison.MustBe(FileDiff.Same, "result state"); sut.OddProperty.MustBe(null, "odd property"); sut.NextStep.MustBe(FileTask.Ignore); sut.Target.MustBe(Target.Both); }
private SyncableFileRemote RemoteFileInfo(SyncableFileRemote rem) { if (rem == null) { return(null); } return(new SyncableFileRemote { Name = rem.Name, Size = rem.Size, Version = rem.Version ?? "", SHA1 = rem.SHA1, Nid = rem.Nid, Vid = rem.Vid, Fid = rem.Fid //UrlOrPath = $"fid: {rem.Fid}" }); }
private async Task <FileContentDto> DownloadFile(SyncableFileRemote node, CancellationToken cancelToken) { FileContentDto ret = null; var list = await _client.Get <List <FileContentDto> > (_urlPattern.f(node.Fid), cancelToken); if (list == null) { return(Error_(ret, "_client.Get<List<FileContentDto>>() == NULL", "")); } if (list.Count == 0) { return(Warn_(ret, "Remote file not found in server.", $"[nid: {node.Nid}] {node.Name}")); } if (list.Count > 1) { return(Warn_(ret, "Duplicate files found in server.", string.Join(", ", list.Select(x => x.fid)))); } return(Trace_(list[0], "Successfully downloaded file content from server", $"{node.Name}")); }