Add option for user to choose custom temp folder
This commit is contained in:
parent
44feab9eb2
commit
b5519c4875
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Dinah.Core;
|
using Dinah.Core;
|
||||||
|
|||||||
@ -11,42 +11,30 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AaxDecrypter
|
namespace AaxDecrypter
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>A resumable, simultaneous file downloader and reader. </summary>
|
||||||
/// A resumable, simultaneous file downloader and reader.
|
|
||||||
/// </summary>
|
|
||||||
public class NetworkFileStream : Stream, IUpdatable
|
public class NetworkFileStream : Stream, IUpdatable
|
||||||
{
|
{
|
||||||
public event EventHandler Updated;
|
public event EventHandler Updated;
|
||||||
|
|
||||||
#region Public Properties
|
#region Public Properties
|
||||||
|
|
||||||
/// <summary>
|
/// <summary> Location to save the downloaded data. </summary>
|
||||||
/// Location to save the downloaded data.
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty(Required = Required.Always)]
|
[JsonProperty(Required = Required.Always)]
|
||||||
public string SaveFilePath { get; }
|
public string SaveFilePath { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary> Http(s) address of the file to download. </summary>
|
||||||
/// Http(s) address of the file to download.
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty(Required = Required.Always)]
|
[JsonProperty(Required = Required.Always)]
|
||||||
public Uri Uri { get; private set; }
|
public Uri Uri { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary> Http headers to be sent to the server with the request. </summary>
|
||||||
/// Http headers to be sent to the server with the request.
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty(Required = Required.Always)]
|
[JsonProperty(Required = Required.Always)]
|
||||||
public Dictionary<string, string> RequestHeaders { get; private set; }
|
public Dictionary<string, string> RequestHeaders { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary> The position in <see cref="SaveFilePath"/> that has been written and flushed to disk. </summary>
|
||||||
/// The position in <see cref="SaveFilePath"/> that has been written and flushed to disk.
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty(Required = Required.Always)]
|
[JsonProperty(Required = Required.Always)]
|
||||||
public long WritePosition { get; private set; }
|
public long WritePosition { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary> The total length of the <see cref="Uri"/> file to download. </summary>
|
||||||
/// The total length of the <see cref="Uri"/> file to download.
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty(Required = Required.Always)]
|
[JsonProperty(Required = Required.Always)]
|
||||||
public long ContentLength { get; private set; }
|
public long ContentLength { get; private set; }
|
||||||
|
|
||||||
@ -76,9 +64,7 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
|
|
||||||
/// <summary>
|
/// <summary> A resumable, simultaneous file downloader and reader. </summary>
|
||||||
/// A resumable, simultaneous file downloader and reader.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="saveFilePath">Path to a location on disk to save the downloaded data from <paramref name="uri"/></param>
|
/// <param name="saveFilePath">Path to a location on disk to save the downloaded data from <paramref name="uri"/></param>
|
||||||
/// <param name="uri">Http(s) address of the file to download.</param>
|
/// <param name="uri">Http(s) address of the file to download.</param>
|
||||||
/// <param name="writePosition">The position in <paramref name="uri"/> to begin downloading.</param>
|
/// <param name="writePosition">The position in <paramref name="uri"/> to begin downloading.</param>
|
||||||
@ -111,9 +97,7 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
#region Downloader
|
#region Downloader
|
||||||
|
|
||||||
/// <summary>
|
/// <summary> Update the <see cref="JsonFilePersister"/>. </summary>
|
||||||
/// Update the <see cref="JsonFilePersister"/>.
|
|
||||||
/// </summary>
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
RequestHeaders["Range"] = $"bytes={WritePosition}-";
|
RequestHeaders["Range"] = $"bytes={WritePosition}-";
|
||||||
@ -127,9 +111,7 @@ namespace AaxDecrypter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary> Set a different <see cref="System.Uri"/> to the same file targeted by this instance of <see cref="NetworkFileStream"/> </summary>
|
||||||
/// Set a different <see cref="System.Uri"/> to the same file targeted by this instance of <see cref="NetworkFileStream"/>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uriToSameFile">New <see cref="System.Uri"/> host must match existing host.</param>
|
/// <param name="uriToSameFile">New <see cref="System.Uri"/> host must match existing host.</param>
|
||||||
public void SetUriForSameFile(Uri uriToSameFile)
|
public void SetUriForSameFile(Uri uriToSameFile)
|
||||||
{
|
{
|
||||||
@ -295,9 +277,7 @@ namespace AaxDecrypter
|
|||||||
return _readFile.Position = newPosition;
|
return _readFile.Position = newPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>Blocks until the file has downloaded to at least <paramref name="requiredPosition"/>, then returns. </summary>
|
||||||
/// Blocks until the file has downloaded to at least <paramref name="requiredPosition"/>, then returns.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="requiredPosition">The minimum required flished data length in <see cref="SaveFilePath"/>.</param>
|
/// <param name="requiredPosition">The minimum required flished data length in <see cref="SaveFilePath"/>.</param>
|
||||||
private void WaitToPosition(long requiredPosition)
|
private void WaitToPosition(long requiredPosition)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -351,21 +351,27 @@
|
|||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</controls:GroupBox>
|
</controls:GroupBox>
|
||||||
|
<controls:GroupBox
|
||||||
|
Grid.Row="2"
|
||||||
|
Margin="5"
|
||||||
|
BorderWidth="1"
|
||||||
|
Label="Temporary Files Location">
|
||||||
|
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Grid.Row="2"
|
|
||||||
Margin="5" >
|
Margin="5" >
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="0,0,0,10"
|
Margin="0,0,0,10"
|
||||||
Text="{Binding DownloadDecryptSettings.InProgressDescriptionText}" />
|
Text="{Binding DownloadDecryptSettings.InProgressDescriptionText}" />
|
||||||
|
|
||||||
<controls:DirectorySelectControl
|
<controls:DirectoryOrCustomSelectControl
|
||||||
SubDirectory="Libation\DecryptInProgress"
|
SubDirectory="Libation"
|
||||||
SelectedDirectory="{Binding DownloadDecryptSettings.InProgressDirectory, Mode=TwoWay}" />
|
Directory="{Binding DownloadDecryptSettings.InProgressDirectory, Mode=TwoWay}"
|
||||||
|
KnownDirectories="{Binding DownloadDecryptSettings.KnownDirectories}" />
|
||||||
|
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</controls:GroupBox>
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
Grid.Row="3"
|
Grid.Row="3"
|
||||||
|
|||||||
@ -9,6 +9,7 @@ using ReactiveUI;
|
|||||||
using Dinah.Core;
|
using Dinah.Core;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FileManager;
|
using FileManager;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace LibationAvalonia.Dialogs
|
namespace LibationAvalonia.Dialogs
|
||||||
{
|
{
|
||||||
@ -227,7 +228,6 @@ namespace LibationAvalonia.Dialogs
|
|||||||
|
|
||||||
public class DownloadDecryptSettings : ViewModels.ViewModelBase, ISettingsDisplay
|
public class DownloadDecryptSettings : ViewModels.ViewModelBase, ISettingsDisplay
|
||||||
{
|
{
|
||||||
|
|
||||||
private bool _badBookAsk;
|
private bool _badBookAsk;
|
||||||
private bool _badBookAbort;
|
private bool _badBookAbort;
|
||||||
private bool _badBookRetry;
|
private bool _badBookRetry;
|
||||||
@ -242,7 +242,16 @@ namespace LibationAvalonia.Dialogs
|
|||||||
LoadSettings(config);
|
LoadSettings(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Configuration.KnownDirectories InProgressDirectory { get; set; }
|
public List<Configuration.KnownDirectories> 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)
|
public void LoadSettings(Configuration config)
|
||||||
{
|
{
|
||||||
BadBookAsk = config.BadBook is Configuration.BadBookAction.Ask;
|
BadBookAsk = config.BadBook is Configuration.BadBookAction.Ask;
|
||||||
@ -252,9 +261,7 @@ namespace LibationAvalonia.Dialogs
|
|||||||
FolderTemplate = config.FolderTemplate;
|
FolderTemplate = config.FolderTemplate;
|
||||||
FileTemplate = config.FileTemplate;
|
FileTemplate = config.FileTemplate;
|
||||||
ChapterFileTemplate = config.ChapterFileTemplate;
|
ChapterFileTemplate = config.ChapterFileTemplate;
|
||||||
InProgressDirectory
|
InProgressDirectory = config.InProgress;
|
||||||
= config.InProgress == Configuration.AppDir_Absolute ? Configuration.KnownDirectories.AppDir
|
|
||||||
: Configuration.GetKnownDirectory(config.InProgress);
|
|
||||||
UseCoverAsFolderIcon = config.UseCoverAsFolderIcon;
|
UseCoverAsFolderIcon = config.UseCoverAsFolderIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,9 +296,7 @@ namespace LibationAvalonia.Dialogs
|
|||||||
config.FolderTemplate = FolderTemplate;
|
config.FolderTemplate = FolderTemplate;
|
||||||
config.FileTemplate = FileTemplate;
|
config.FileTemplate = FileTemplate;
|
||||||
config.ChapterFileTemplate = ChapterFileTemplate;
|
config.ChapterFileTemplate = ChapterFileTemplate;
|
||||||
config.InProgress
|
config.InProgress = InProgressDirectory;
|
||||||
= InProgressDirectory is Configuration.KnownDirectories.AppDir ? Configuration.AppDir_Absolute
|
|
||||||
: Configuration.GetKnownDirectoryPath(InProgressDirectory);
|
|
||||||
|
|
||||||
config.UseCoverAsFolderIcon = UseCoverAsFolderIcon;
|
config.UseCoverAsFolderIcon = UseCoverAsFolderIcon;
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ namespace LibationFileManager
|
|||||||
[Description("The same folder that Libation is running from")]
|
[Description("The same folder that Libation is running from")]
|
||||||
AppDir = 2,
|
AppDir = 2,
|
||||||
|
|
||||||
[Description("Windows temporary folder")]
|
[Description("System temporary folder")]
|
||||||
WinTemp = 3,
|
WinTemp = 3,
|
||||||
|
|
||||||
[Description("My Documents")]
|
[Description("My Documents")]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user