protected override async Task <string> ExecuteInternal() { var filePaths = new Queue <string>(FileRetriever.GetSortedFilePathsRecursively(PathService.Source)); var copyTasks = CreateFixedBatchOfCopyTasks(filePaths); var finishedTask = Task.FromResult(string.Empty); while (copyTasks.Any()) { finishedTask = await Task.WhenAny(copyTasks); if (CancellationTokenSource.IsCancellationRequested) { break; } copyTasks.Remove(finishedTask); if (filePaths.Any()) { copyTasks.Add(BuildNextTask(filePaths.Dequeue())); } } //Return the result of the last task to finish. //NB: awaiting does not wrap the OperationCanceledException in an AggreagateException, //while calling finishedTask.Result does so, and prevents the error handling on OCE in the base class from running return(await finishedTask); }
public RepoConfigManager( FileRetriever fileRetriever, RepoConfigRepository repoConfigRepository ) { this.fileRetriever = fileRetriever; this.repoConfigRepository = repoConfigRepository; }
public bool FileVersionExists(object repositoryId, long version) { if (fileRetriever == null) { fileRetriever = new FileRetriever(this.connectionSettings); } return(fileRetriever.CanGetFile((string)repositoryId, version)); }
public string GetFile(object repositoryId, long version, TemporaryDirectory tempDir) { if (fileRetriever == null) { fileRetriever = new FileRetriever(this.connectionSettings); } return(fileRetriever.GetFile((string)repositoryId, version, tempDir)); }
private void HandleCancellation() { _info.OnNext(Notification.Clear); _info.OnNext(Notification.Append("You've canceled the task, and you're now left with the following fully copied files:")); var alreadyCopiedFilePaths = FileRetriever.GetFilePathsRecursively(PathService.Destination); alreadyCopiedFilePaths.ForEach(path => _info.OnNext(Notification.Append(new FileInfo(path).Name))); }
private void UpdateMovieList(int min, int max, string search) { names = new Dictionary <string, string>(); filepaths = new Dictionary <string, string>(); FileRetriever fileRetriever = new FileRetriever(); files = fileRetriever.GetMovies(min, max); foreach (var file in files) { var name = System.IO.Path.GetFileNameWithoutExtension(file); name = name.Replace(".", " "); if (!filepaths.ContainsKey(name)) { if (search != null && search != "") { bool contains = StringExtensions.Contains(name, search, StringComparison.OrdinalIgnoreCase); if (contains) { filepaths.Add(name, file); List.Items.Add(name); names.Add(file, name); } } else { filepaths.Add(name, file); List.Items.Add(name); names.Add(file, name); } } } var buttonList = files.Take(6); var buttons = new List <Button> { Button1, Button2, Button3, Button4, Button5, Button6 }; var text = new List <TextBlock> { Text1, Text2, Text3, Text4, Text5, Text6 }; for (int i = 0; i < buttons.Count; i++) { var name = System.IO.Path.GetFileNameWithoutExtension(buttonList.ElementAt(i)); text[i].Text = name; } }
public override void HandleRequest(Request request) { if (request is FileInformationRequest) { FileInformationRequest fi_request = request as FileInformationRequest; FileRetriever retriever = new FileRetriever(fi_request.Type, fi_request.Name); FileRecord frecord = retriever.Get(); if (frecord != null) { fi_request.ID = frecord.ID; fi_request.Details = frecord.Details; } request.Handled(); } }
protected override async Task <string> ExecuteInternal() { var filePaths = new Queue <string>(FileRetriever.GetSortedFilePathsRecursively(PathService.Source) .Where(fp => fp.Contains("Silents - Demo - 02") && !fp.EndsWith(".md5"))); var copyTasks = CreateFixedBatchOfCopyTasks(filePaths); var firstTaskToFinish = Task.FromResult(string.Empty); while (copyTasks.Any()) { firstTaskToFinish = await Task.WhenAny(copyTasks); CancellationTokenSource.Cancel(); break; } //Return the result of the last task to finish. //NB: awaiting does not wrap the OperationCanceledException in an AggreagateException, //while calling finishedTask.Result does so, and prevents the error handling on OCE in the base class from running return(await firstTaskToFinish); }
protected override async Task <string> ExecuteInternal() { var filePaths = new Queue <string>(FileRetriever.GetSortedFilePathsRecursively(PathService.Source) .Where(fp => fp.Contains(".m4a")) .OrderBy(fp => fp.Contains(".md5") ? 0 : 1)); var copyTasks = CreateFixedBatchOfCopyTasks(filePaths); var path = string.Empty; while (copyTasks.Any()) { var finishedTask = await Task.WhenAny(copyTasks); if (CancellationTokenSource.IsCancellationRequested) { break; } path = await finishedTask; if (!IsValidMd5(path)) { CancellationTokenSource.Cancel(); throw new FileFormatException($"Invalid MD5 for {path}"); } copyTasks.Remove(finishedTask); if (filePaths.Any()) { copyTasks.Add(BuildNextTask(filePaths.Dequeue())); } } //Return the result of the last task to finish. //NB: awaiting does not wrap the OperationCanceledException in an AggreagateException, //while calling finishedTask.Result does so, and prevents the error handling on OCE in the base class from running return(path); }
public DiffTwoFileVersions(VaultRepositoryAuthSettings settings, ExternalToolsSettings externalToolsSettings) : this(settings.Host, settings.Repository, settings.User, settings.Password) { this.externalToolsSettings = externalToolsSettings; fileRetriever = new FileRetriever(settings); }