Remove file watcher from ManualDownloader

This was creating a file watcher in the system configured Downloads
folder.  This folder has absolutely no purpose for WJ as downloads
go to the specified downloads tab.

Additionally, this causes crashes to occur if the Downloads folder
doesn't exist.
This commit is contained in:
Chris Bessent 2021-02-07 16:27:43 -07:00
parent 939e05ff65
commit 20821090c1

View File

@ -13,11 +13,6 @@ namespace Wabbajack.Lib.Downloaders
{
public class ManualDownloader : IDownloader
{
private FileSystemWatcher _watcher;
private Subject<FileEvent> _fileEvents = new Subject<FileEvent>();
private KnownFolder _downloadfolder;
public readonly AsyncLock Lock = new AsyncLock();
class FileEvent
{
public string FullPath { get; set; } = string.Empty;
@ -27,36 +22,6 @@ namespace Wabbajack.Lib.Downloaders
public ManualDownloader()
{
_downloadfolder = new KnownFolder(KnownFolderType.Downloads);
_watcher = new FileSystemWatcher(_downloadfolder.Path);
_watcher.Created += _watcher_Created;
_watcher.Changed += _watcher_Changed;
}
private void _watcher_Changed(object sender, FileSystemEventArgs e)
{
PublishEvent(e);
}
private void _watcher_Created(object sender, FileSystemEventArgs e)
{
PublishEvent(e);
}
private void PublishEvent(FileSystemEventArgs e)
{
try
{
_fileEvents.OnNext(new FileEvent
{
Size = new FileInfo(e.FullPath).Length,
Name = e.Name!,
FullPath = e.FullPath
});
}
catch (IOException)
{
}
}
public async Task<AbstractDownloadState?> GetDownloaderState(dynamic archiveINI, bool quickMode)