diff --git a/Program.cs b/Program.cs index 1315ef7..8bdd2c7 100644 --- a/Program.cs +++ b/Program.cs @@ -152,18 +152,24 @@ namespace ttrss_co_client { var wo = await lingeringTask; var wop = Path.Combine(conf.WorkingDirectory, wo.Item2.guid.ToString(), "workorder.json"); - File.WriteAllText(wop, JsonConvert.SerializeObject(wo.Item2)); //if you tell me it's done, or you need to continue now.... I believe you. switch (wo.Item1) { case Phase2Task.TaskStatus.Done: - File.Delete(wop); - Directory.Delete(Path.Combine(conf.WorkingDirectory, wo.Item2.guid.ToString())); + var workingSubDir = Path.Combine(conf.WorkingDirectory, wo.Item2.guid.ToString()); + foreach(var file in Directory.GetFiles(workingSubDir, "*.*", SearchOption.AllDirectories)) + { + File.Delete(file); + } + //imo this next line should also handle the above, but apparently I'm alone in that. + Directory.Delete(workingSubDir, true); break; case Phase2Task.TaskStatus.ContinueNow: remainingWork.Add(wo.Item2); break; case Phase2Task.TaskStatus.TryLater: + + File.WriteAllText(wop, JsonConvert.SerializeObject(wo.Item2)); break; } } diff --git a/tasks/PodcastifyAttachment.cs b/tasks/PodcastifyAttachment.cs index f7ef5c3..f55fa52 100644 --- a/tasks/PodcastifyAttachment.cs +++ b/tasks/PodcastifyAttachment.cs @@ -26,9 +26,14 @@ namespace ttrss_co_client.tasks var downloadPath = Path.Combine(workingFolder, headline.title) + extensionUpstream; var downloader = new HttpClient(); sw.Start(); - File.WriteAllBytes(downloadPath, await (await downloader.GetAsync(attachmentLink)).Content.ReadAsByteArrayAsync()); + var dlResult = (await downloader.GetAsync(attachmentLink)); + File.WriteAllBytes(downloadPath, await dlResult.Content.ReadAsByteArrayAsync()); sw.Stop(); - var outputStr = $"{(File.Exists(downloadPath) ? "Success" : "fail")} in {sw.Elapsed}"; + var outputStr = $"{(dlResult.IsSuccessStatusCode ? "Success" : "fail")} in {sw.Elapsed}"; + if(!dlResult.IsSuccessStatusCode) + { + outputStr += $"\n\t{dlResult.StatusCode} - {dlResult.ReasonPhrase}"; + } Console.WriteLine($" {attachmentLink}\n{outputStr}"); await TtrssClient.SetArticleLabel(labelsWRTArticle.First(l => l.caption?.ToLower() == this.TriggerLabel.ToLower()).id, false, headline.id); @@ -45,7 +50,7 @@ namespace ttrss_co_client.tasks Console.WriteLine($"article {headline.id} - podcastifying; {podcastTitle}"); await TtrssClient.UpdateArticleNote($"{headline.note}\n[{DateTime.Now.ToString("o")}] - podcastify attachment (dl): {outputStr}", headline.id); - if (!File.Exists(downloadPath)) + if (!dlResult.IsSuccessStatusCode) { return null; }