public async Task <bool> Run(int folderNid, List <RemoteVsLocalFile> list, string targetDir, CancellationToken cancelToken, string subUrlPattern) { HasReplacement = false; _targetDir = targetDir; _foldrNid = folderNid; _cancelToken = cancelToken; _downloadr = ForwardLogs(new D7FileDownloader(_targetDir, subUrlPattern, _fs, _client)); _foldrNode = null; foreach (var item in list) { switch (item.Target) { case Target.Remote: await ActOnRemote(item, cancelToken); break; case Target.Local: await ActOnLocal(item, cancelToken); break; case Target.Both: await ActOnRemote(item, cancelToken); await ActOnLocal(item, cancelToken); break; default: Warn_n($"Unsupported Target: ‹{item.Target}›", ""); break; } } if (_foldrNode != null) { return(await SaveFolderNode(cancelToken)); } else { return(true); } }
private async Task <bool> SaveFolderNode(CancellationToken cancelToken) { Debug_n("Updating App node to include/exclude file nodes...", ""); // unset the flag to enable downloads _foldrNode.field_currently_updating.und.Clear(); _foldrNode.field_currently_updating.und.Add(und.Value(0)); _foldrNode = await _client.Put(_foldrNode, cancelToken); if (_foldrNode.IsValidNode()) { return(Debug_n("Successfully updated App node.", "")); } else { return(Warn_n("Something went wrong in updating App node.", "")); } }
private async Task <bool> LoadFolderNodeIfNull() { if (_foldrNode != null) { return(true); } _foldrNode = await _client.Node <SyncableFolderDto>(_foldrNid, _cancelToken); // set the flag to disable downloads _foldrNode.field_currently_updating.und.Clear(); _foldrNode.field_currently_updating.und.Add(und.Value(1)); _foldrNode = await _client.Put(_foldrNode, _cancelToken); if (_foldrNode.IsValidNode()) { return(Debug_n("Flag set to temporarily disable downloads.", "")); } else { return(Warn_n("Something went wrong in updating App node.", "")); } }