Better error when download service is unavailable
This commit is contained in:
parent
79e0a8fba7
commit
d8a0124b68
@ -2,6 +2,7 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DataLayer;
|
using DataLayer;
|
||||||
|
using Dinah.Core;
|
||||||
using Dinah.Core.ErrorHandling;
|
using Dinah.Core.ErrorHandling;
|
||||||
using FileManager;
|
using FileManager;
|
||||||
|
|
||||||
@ -44,11 +45,17 @@ namespace FileLiberator
|
|||||||
tempAaxFilename,
|
tempAaxFilename,
|
||||||
(p) => api.DownloadAaxWorkaroundAsync(libraryBook.Book.AudibleProductId, tempAaxFilename, p));
|
(p) => api.DownloadAaxWorkaroundAsync(libraryBook.Book.AudibleProductId, tempAaxFilename, p));
|
||||||
|
|
||||||
// if bad file download, a 0-33 byte file will be created
|
|
||||||
System.Threading.Thread.Sleep(100);
|
System.Threading.Thread.Sleep(100);
|
||||||
|
// if bad file download, a 0-33 byte file will be created
|
||||||
|
// if service unavailable, a 52 byte string will be saved as file
|
||||||
if (new FileInfo(actualFilePath).Length < 100)
|
if (new FileInfo(actualFilePath).Length < 100)
|
||||||
{
|
{
|
||||||
|
var contents = File.ReadAllText(actualFilePath);
|
||||||
File.Delete(actualFilePath);
|
File.Delete(actualFilePath);
|
||||||
|
|
||||||
|
var unavailable = "Content Delivery Companion Service is not available.";
|
||||||
|
if (contents.StartsWithInsensitive(unavailable))
|
||||||
|
throw new Exception(unavailable);
|
||||||
throw new Exception("Error downloading file");
|
throw new Exception("Error downloading file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user