From b5519c4875470c22ac86cb9dd5748e9978bff0e3 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Sat, 17 Dec 2022 11:42:55 -0700 Subject: [PATCH] Add option for user to choose custom temp folder --- Source/AaxDecrypter/AudiobookDownloadBase.cs | 1 - Source/AaxDecrypter/NetworkFileStream.cs | 40 +++++-------------- .../Dialogs/SettingsDialog.axaml | 16 +++++--- .../Dialogs/SettingsDialog.axaml.cs | 21 ++++++---- .../Configuration.KnownDirectories.cs | 2 +- 5 files changed, 35 insertions(+), 45 deletions(-) diff --git a/Source/AaxDecrypter/AudiobookDownloadBase.cs b/Source/AaxDecrypter/AudiobookDownloadBase.cs index f2347e94..89a94f2f 100644 --- a/Source/AaxDecrypter/AudiobookDownloadBase.cs +++ b/Source/AaxDecrypter/AudiobookDownloadBase.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using Dinah.Core; diff --git a/Source/AaxDecrypter/NetworkFileStream.cs b/Source/AaxDecrypter/NetworkFileStream.cs index 49a911db..2bd4863b 100644 --- a/Source/AaxDecrypter/NetworkFileStream.cs +++ b/Source/AaxDecrypter/NetworkFileStream.cs @@ -11,42 +11,30 @@ using System.Threading.Tasks; namespace AaxDecrypter { - /// - /// A resumable, simultaneous file downloader and reader. - /// + /// A resumable, simultaneous file downloader and reader. public class NetworkFileStream : Stream, IUpdatable { public event EventHandler Updated; #region Public Properties - /// - /// Location to save the downloaded data. - /// + /// Location to save the downloaded data. [JsonProperty(Required = Required.Always)] public string SaveFilePath { get; } - /// - /// Http(s) address of the file to download. - /// + /// Http(s) address of the file to download. [JsonProperty(Required = Required.Always)] public Uri Uri { get; private set; } - /// - /// Http headers to be sent to the server with the request. - /// + /// Http headers to be sent to the server with the request. [JsonProperty(Required = Required.Always)] public Dictionary RequestHeaders { get; private set; } - /// - /// The position in that has been written and flushed to disk. - /// + /// The position in that has been written and flushed to disk. [JsonProperty(Required = Required.Always)] public long WritePosition { get; private set; } - /// - /// The total length of the file to download. - /// + /// The total length of the file to download. [JsonProperty(Required = Required.Always)] public long ContentLength { get; private set; } @@ -76,9 +64,7 @@ namespace AaxDecrypter #region Constructor - /// - /// A resumable, simultaneous file downloader and reader. - /// + /// A resumable, simultaneous file downloader and reader. /// Path to a location on disk to save the downloaded data from /// Http(s) address of the file to download. /// The position in to begin downloading. @@ -111,9 +97,7 @@ namespace AaxDecrypter #region Downloader - /// - /// Update the . - /// + /// Update the . private void Update() { RequestHeaders["Range"] = $"bytes={WritePosition}-"; @@ -127,9 +111,7 @@ namespace AaxDecrypter } } - /// - /// Set a different to the same file targeted by this instance of - /// + /// Set a different to the same file targeted by this instance of /// New host must match existing host. public void SetUriForSameFile(Uri uriToSameFile) { @@ -295,9 +277,7 @@ namespace AaxDecrypter return _readFile.Position = newPosition; } - /// - /// Blocks until the file has downloaded to at least , then returns. - /// + /// Blocks until the file has downloaded to at least , then returns. /// The minimum required flished data length in . private void WaitToPosition(long requiredPosition) { diff --git a/Source/LibationAvalonia/Dialogs/SettingsDialog.axaml b/Source/LibationAvalonia/Dialogs/SettingsDialog.axaml index 0224c16c..b7c76037 100644 --- a/Source/LibationAvalonia/Dialogs/SettingsDialog.axaml +++ b/Source/LibationAvalonia/Dialogs/SettingsDialog.axaml @@ -351,21 +351,27 @@ - - + + - + + KnownDirectories { get; } = new() + { + Configuration.KnownDirectories.WinTemp, + Configuration.KnownDirectories.UserProfile, + Configuration.KnownDirectories.AppDir, + Configuration.KnownDirectories.MyDocs, + Configuration.KnownDirectories.LibationFiles + }; + + public string InProgressDirectory { get; set; } public void LoadSettings(Configuration config) { BadBookAsk = config.BadBook is Configuration.BadBookAction.Ask; @@ -252,9 +261,7 @@ namespace LibationAvalonia.Dialogs FolderTemplate = config.FolderTemplate; FileTemplate = config.FileTemplate; ChapterFileTemplate = config.ChapterFileTemplate; - InProgressDirectory - = config.InProgress == Configuration.AppDir_Absolute ? Configuration.KnownDirectories.AppDir - : Configuration.GetKnownDirectory(config.InProgress); + InProgressDirectory = config.InProgress; UseCoverAsFolderIcon = config.UseCoverAsFolderIcon; } @@ -289,9 +296,7 @@ namespace LibationAvalonia.Dialogs config.FolderTemplate = FolderTemplate; config.FileTemplate = FileTemplate; config.ChapterFileTemplate = ChapterFileTemplate; - config.InProgress - = InProgressDirectory is Configuration.KnownDirectories.AppDir ? Configuration.AppDir_Absolute - : Configuration.GetKnownDirectoryPath(InProgressDirectory); + config.InProgress = InProgressDirectory; config.UseCoverAsFolderIcon = UseCoverAsFolderIcon; diff --git a/Source/LibationFileManager/Configuration.KnownDirectories.cs b/Source/LibationFileManager/Configuration.KnownDirectories.cs index c69d16a1..5ad6a75e 100644 --- a/Source/LibationFileManager/Configuration.KnownDirectories.cs +++ b/Source/LibationFileManager/Configuration.KnownDirectories.cs @@ -25,7 +25,7 @@ namespace LibationFileManager [Description("The same folder that Libation is running from")] AppDir = 2, - [Description("Windows temporary folder")] + [Description("System temporary folder")] WinTemp = 3, [Description("My Documents")]