Reused yellow stoplight to indicate and interrupted and resumable download.

This commit is contained in:
Michael Bucari-Tovo 2021-07-03 22:06:56 -06:00
parent 05426eb618
commit 6d856f73e7
5 changed files with 14 additions and 15 deletions

View File

@ -213,8 +213,7 @@ namespace FileLiberator
} }
public bool Validate(LibraryBook libraryBook) public bool Validate(LibraryBook libraryBook)
=> !AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId) => !AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId);
&& !AudibleFileStorage.AAX.Exists(libraryBook.Book.AudibleProductId);
public void Cancel() public void Cancel()
{ {

View File

@ -9,7 +9,7 @@ using Dinah.Core.Collections.Generic;
namespace FileManager namespace FileManager
{ {
// could add images here, but for now images are stored in a well-known location // could add images here, but for now images are stored in a well-known location
public enum FileType { Unknown, Audio, AAX, PDF } public enum FileType { Unknown, Audio, AAXC, PDF }
/// <summary> /// <summary>
/// Files are large. File contents are never read by app. /// Files are large. File contents are never read by app.
@ -25,7 +25,7 @@ namespace FileManager
#region static #region static
public static AudioFileStorage Audio { get; } = new AudioFileStorage(); public static AudioFileStorage Audio { get; } = new AudioFileStorage();
public static AudibleFileStorage AAX { get; } = new AaxFileStorage(); public static AudibleFileStorage AAXC { get; } = new AaxcFileStorage();
public static AudibleFileStorage PDF { get; } = new PdfFileStorage(); public static AudibleFileStorage PDF { get; } = new PdfFileStorage();
public static string DownloadsInProgress public static string DownloadsInProgress
@ -77,7 +77,7 @@ namespace FileManager
public FileType FileType => (FileType)Value; public FileType FileType => (FileType)Value;
private IEnumerable<string> extensions_noDots { get; } private IEnumerable<string> extensions_noDots { get; }
private string extAggr { get; } private string extAggr { get; }
protected AudibleFileStorage(FileType fileType) : base((int)fileType, fileType.ToString()) protected AudibleFileStorage(FileType fileType) : base((int)fileType, fileType.ToString())
{ {
@ -153,16 +153,16 @@ namespace FileManager
} }
} }
public class AaxFileStorage : AudibleFileStorage public class AaxcFileStorage : AudibleFileStorage
{ {
public override string[] Extensions { get; } = new[] { "aax" }; public override string[] Extensions { get; } = new[] { "aaxc" };
// we always want to use the latest config value, therefore // we always want to use the latest config value, therefore
// - DO use 'get' arrow "=>" // - DO use 'get' arrow "=>"
// - do NOT use assign "=" // - do NOT use assign "="
public override string StorageDirectory => DownloadsFinal; public override string StorageDirectory => DownloadsInProgress;
public AaxFileStorage() : base(FileType.AAX) { } public AaxcFileStorage() : base(FileType.AAXC) { }
} }
public class PdfFileStorage : AudibleFileStorage public class PdfFileStorage : AudibleFileStorage

View File

@ -117,7 +117,7 @@ namespace LibationWinForms
{ {
if (AudibleFileStorage.Audio.Exists(productId)) if (AudibleFileStorage.Audio.Exists(productId))
return AudioFileState.full; return AudioFileState.full;
if (AudibleFileStorage.AAX.Exists(productId)) if (AudibleFileStorage.AAXC.Exists(productId))
return AudioFileState.aax; return AudioFileState.aax;
return AudioFileState.none; return AudioFileState.none;
} }

View File

@ -26,11 +26,11 @@ namespace LibationWinForms
[Browsable(false)] [Browsable(false)]
public IEnumerable<string> TagsEnumerated => book.UserDefinedItem.TagsEnumerated; public IEnumerable<string> TagsEnumerated => book.UserDefinedItem.TagsEnumerated;
public enum LiberatedState { NotDownloaded, DRM, Liberated } public enum LiberatedState { NotDownloaded, PartialDownload, Liberated }
[Browsable(false)] [Browsable(false)]
public LiberatedState Liberated_Status public LiberatedState Liberated_Status
=> FileManager.AudibleFileStorage.Audio.Exists(book.AudibleProductId) ? LiberatedState.Liberated => FileManager.AudibleFileStorage.Audio.Exists(book.AudibleProductId) ? LiberatedState.Liberated
: FileManager.AudibleFileStorage.AAX.Exists(book.AudibleProductId) ? LiberatedState.DRM : FileManager.AudibleFileStorage.AAXC.Exists(book.AudibleProductId) ? LiberatedState.PartialDownload
: LiberatedState.NotDownloaded; : LiberatedState.NotDownloaded;
public enum PdfState { NoPdf, Downloaded, NotDownloaded } public enum PdfState { NoPdf, Downloaded, NotDownloaded }

View File

@ -126,7 +126,7 @@ namespace LibationWinForms
var libState = liberatedStatus switch var libState = liberatedStatus switch
{ {
GridEntry.LiberatedState.Liberated => "Liberated", GridEntry.LiberatedState.Liberated => "Liberated",
GridEntry.LiberatedState.DRM => "Downloaded but needs DRM removed", GridEntry.LiberatedState.PartialDownload => "File has been at least\r\npartially downloaded",
GridEntry.LiberatedState.NotDownloaded => "Book NOT downloaded", GridEntry.LiberatedState.NotDownloaded => "Book NOT downloaded",
_ => throw new Exception("Unexpected liberation state") _ => throw new Exception("Unexpected liberation state")
}; };
@ -142,7 +142,7 @@ namespace LibationWinForms
var text = libState + pdfState; var text = libState + pdfState;
if (liberatedStatus == GridEntry.LiberatedState.NotDownloaded || if (liberatedStatus == GridEntry.LiberatedState.NotDownloaded ||
liberatedStatus == GridEntry.LiberatedState.DRM || liberatedStatus == GridEntry.LiberatedState.PartialDownload ||
pdfStatus == GridEntry.PdfState.NotDownloaded) pdfStatus == GridEntry.PdfState.NotDownloaded)
text += "\r\nClick to complete"; text += "\r\nClick to complete";
@ -154,7 +154,7 @@ namespace LibationWinForms
{ {
var image_lib var image_lib
= liberatedStatus == GridEntry.LiberatedState.NotDownloaded ? "red" = liberatedStatus == GridEntry.LiberatedState.NotDownloaded ? "red"
: liberatedStatus == GridEntry.LiberatedState.DRM ? "yellow" : liberatedStatus == GridEntry.LiberatedState.PartialDownload ? "yellow"
: liberatedStatus == GridEntry.LiberatedState.Liberated ? "green" : liberatedStatus == GridEntry.LiberatedState.Liberated ? "green"
: throw new Exception("Unexpected liberation state"); : throw new Exception("Unexpected liberation state");
var image_pdf var image_pdf