Patch for PR #76

This commit is contained in:
erri120 2019-10-10 14:16:14 +02:00
parent 65d2cc7d81
commit 70c8da5508
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
2 changed files with 10 additions and 29 deletions

View File

@ -21,6 +21,7 @@ namespace Wabbajack
internal class AppState : ViewModel, IDataErrorInfo internal class AppState : ViewModel, IDataErrorInfo
{ {
private const int MAX_CACHE_SIZE = 10; private const int MAX_CACHE_SIZE = 10;
private bool installing = false;
private string _mo2Folder; private string _mo2Folder;
@ -72,12 +73,12 @@ namespace Wabbajack
Dirty = false; Dirty = false;
dispatcher = d; dispatcher = d;
var th = new Thread(() => UpdateLoop()) slideshowThread = new Thread(() => UpdateLoop())
{ {
Priority = ThreadPriority.BelowNormal, Priority = ThreadPriority.BelowNormal,
IsBackground = true IsBackground = true
}; };
th.Start(); slideshowThread.Start();
} }
private void SetupSlideshow() private void SetupSlideshow()
@ -125,8 +126,8 @@ namespace Wabbajack
} }
} }
private int _QueueProgress; private int _queueProgress;
public int QueueProgress { get => _QueueProgress; set => this.RaiseAndSetIfChanged(ref _QueueProgress, value); } public int QueueProgress { get => _queueProgress; set => this.RaiseAndSetIfChanged(ref _queueProgress, value); }
private List<CPUStatus> InternalStatus { get; } = new List<CPUStatus>(); private List<CPUStatus> InternalStatus { get; } = new List<CPUStatus>();
public string LogFile { get; } public string LogFile { get; }
@ -380,7 +381,7 @@ namespace Wabbajack
Dirty = false; Dirty = false;
} }
if (slidesQueue.Any()) if (slidesQueue != null && slidesQueue.Any())
{ {
if (DateTime.Now - _lastSlideShowUpdate > TimeSpan.FromSeconds(10)) if (DateTime.Now - _lastSlideShowUpdate > TimeSpan.FromSeconds(10))
{ {
@ -392,7 +393,7 @@ namespace Wabbajack
} }
private void UpdateSlideShowItem(bool fromLoop) private void UpdateSlideShowItem(bool fromLoop)
{ {
if (EnableSlideShow) if (EnableSlideShow && slideshowThread != null && installing)
{ {
// max cached files achieved // max cached files achieved
if (_cachedSlides.Count >= MAX_CACHE_SIZE) if (_cachedSlides.Count >= MAX_CACHE_SIZE)
@ -551,8 +552,6 @@ namespace Wabbajack
if (QueueRandomSlide(true, false)) if (QueueRandomSlide(true, false))
turns++; turns++;
else
continue;
} }
} }
@ -648,12 +647,7 @@ namespace Wabbajack
UIReady = false; UIReady = false;
if (Mode == TaskMode.INSTALLING) if (Mode == TaskMode.INSTALLING)
{ {
slideshowThread = new Thread(() => UpdateLoop()) installing = true;
{
Priority = ThreadPriority.BelowNormal,
IsBackground = true
};
slideshowThread.Start();
var installer = new Installer(_modListPath, _modList, Location) var installer = new Installer(_modListPath, _modList, Location)
{ {
DownloadFolder = DownloadLocation DownloadFolder = DownloadLocation
@ -676,6 +670,7 @@ namespace Wabbajack
{ {
UIReady = true; UIReady = true;
Running = false; Running = false;
installing = false;
slideshowThread.Abort(); slideshowThread.Abort();
} }
}) })
@ -727,20 +722,6 @@ namespace Wabbajack
UIReady = true; UIReady = true;
} }
} }
private bool IsFileLocked(string path)
{
bool result = false;
try
{
using (var stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.None))
{
result = false;
}
}
catch (IOException) { result = true; }
return result;
}
} }
public class CPUStatus public class CPUStatus

View File

@ -677,7 +677,7 @@ namespace Wabbajack
{ {
var cruft_files = new HashSet<string> var cruft_files = new HashSet<string>
{ {
"7z.dll", "7z.exe", "vfs_staged_files\\", "nexus.key_cache", "patch_cache\\", "slideshow_cache\\", "7z.dll", "7z.exe", "vfs_staged_files\\", "nexus.key_cache", "patch_cache\\",
Consts.NexusCacheDirectory + "\\" Consts.NexusCacheDirectory + "\\"
}; };
return source => return source =>