diff --git a/Binaries/Steam Library Manager.exe b/Binaries/Steam Library Manager.exe index b86b20af..1ed9ce8a 100644 Binary files a/Binaries/Steam Library Manager.exe and b/Binaries/Steam Library Manager.exe differ diff --git a/Binaries/Version.txt b/Binaries/Version.txt index 0a8f276a..95b69690 100644 --- a/Binaries/Version.txt +++ b/Binaries/Version.txt @@ -1 +1 @@ -1.5.0.4|Bug fixes \ No newline at end of file +1.5.0.5|Bug fixes \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c1620b6..e04b4a2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). +## [1.5.0.5] - 2018-01-08 + +### Fixed + +- FileNotFoundException happens on file removal which caused by cached file properties. +- InvalidOperationException happens on updating junk list. +- Workshop files for tasked items are being detected by junk cleaner. +- ArgumentException happens on getting disk details for mapped network locations.(Haven't tried mapped location yet, not sure if it works or not) +- ArgumentOutOfRangeException on generating SLM library list. +- Handling of UnauthorizedAccessException on CopyFilesAsync/Steam method. +- InvalidOperationException happens on Updating application list for Steam. + ## [1.5.0.4] - 2018-01-06 ### Added diff --git a/Source/Steam Library Manager.sln b/Source/Steam Library Manager.sln index 282c4946..f60b80c9 100644 --- a/Source/Steam Library Manager.sln +++ b/Source/Steam Library Manager.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2010 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Steam Library Manager", "Steam Library Manager\Steam Library Manager.csproj", "{1E4D6DFF-D115-441D-AEA8-F22F60B2CBE4}" EndProject @@ -19,4 +19,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BAC111FB-A259-47CA-987C-ECC3D96BDA53} + EndGlobalSection EndGlobal diff --git a/Source/Steam Library Manager/App.xaml.cs b/Source/Steam Library Manager/App.xaml.cs index 60603513..86656ec7 100644 --- a/Source/Steam Library Manager/App.xaml.cs +++ b/Source/Steam Library Manager/App.xaml.cs @@ -29,7 +29,6 @@ private void Application_DispatcherUnhandledException(object sender, System.Wind { e.Exception.Data.Add(".Net", Functions.SLM.Get45PlusFromRegistry()); MessageBox.Show(e.Exception.ToString(), "Exception Caught", MessageBoxButton.OK, MessageBoxImage.Error); - System.Diagnostics.Debug.WriteLine(e.Exception); Definitions.SLM.RavenClient.Capture(new SharpRaven.Data.SentryEvent(e.Exception)); e.Handled = true; } diff --git a/Source/Steam Library Manager/Definitions/AppInfo.cs b/Source/Steam Library Manager/Definitions/AppInfo.cs index 29190cbf..8fefcba5 100644 --- a/Source/Steam Library Manager/Definitions/AppInfo.cs +++ b/Source/Steam Library Manager/Definitions/AppInfo.cs @@ -323,116 +323,186 @@ public async void CopyFilesAsync(List.TaskInfo CurrentTask, CancellationToken ca { POptions.MaxDegreeOfParallelism = 1; - Parallel.ForEach(AppFiles.Where(x => (x as FileInfo).Length > Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), POptions, CurrentFile => + Parallel.ForEach(AppFiles.Where(x => (x as FileInfo).Length > Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), POptions, async CurrentFile => { - FileInfo NewFile = new FileInfo(CurrentFile.FullName.Replace(Library.Steam.SteamAppsFolder.FullName, CurrentTask.TargetLibrary.Steam.SteamAppsFolder.FullName)); - - if (!NewFile.Exists || (NewFile.Length != ((FileInfo)CurrentFile).Length || NewFile.LastWriteTime != ((FileInfo)CurrentFile).LastWriteTime)) + try { - if (!NewFile.Directory.Exists) - { - NewFile.Directory.Create(); - CreatedDirectories.Add(NewFile.Directory.FullName); - } + FileInfo NewFile = new FileInfo(CurrentFile.FullName.Replace(Library.Steam.SteamAppsFolder.FullName, CurrentTask.TargetLibrary.Steam.SteamAppsFolder.FullName)); - int currentBlockSize = 0; - byte[] FSBuffer = new byte[8192]; - - using (FileStream CurrentFileContent = ((FileInfo)CurrentFile).Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + if (!NewFile.Exists || (NewFile.Length != ((FileInfo)CurrentFile).Length || NewFile.LastWriteTime != ((FileInfo)CurrentFile).LastWriteTime)) { - using (FileStream NewFileContent = NewFile.OpenWrite()) + if (!NewFile.Directory.Exists) { - CurrentTask.TaskStatusInfo = $"Copying: {CurrentFile.Name} ({Functions.FileSystem.FormatBytes(((FileInfo)CurrentFile).Length)})"; + NewFile.Directory.Create(); + CreatedDirectories.Add(NewFile.Directory.FullName); + } + + int currentBlockSize = 0; + byte[] FSBuffer = new byte[8192]; - while ((currentBlockSize = CurrentFileContent.Read(FSBuffer, 0, FSBuffer.Length)) > 0) + using (FileStream CurrentFileContent = ((FileInfo)CurrentFile).Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + using (FileStream NewFileContent = NewFile.OpenWrite()) { - if (cancellationToken.IsCancellationRequested) - throw (new OperationCanceledException(cancellationToken)); + CurrentTask.TaskStatusInfo = $"Copying: {CurrentFile.Name} ({Functions.FileSystem.FormatBytes(((FileInfo)CurrentFile).Length)})"; - while (Framework.TaskManager.Paused) + while ((currentBlockSize = CurrentFileContent.Read(FSBuffer, 0, FSBuffer.Length)) > 0) { - Task.Delay(100); - } + if (cancellationToken.IsCancellationRequested) + throw (new OperationCanceledException(cancellationToken)); + + while (Framework.TaskManager.Paused) + { + Task.Delay(100); + } - NewFileContent.Write(FSBuffer, 0, currentBlockSize); + NewFileContent.Write(FSBuffer, 0, currentBlockSize); - CurrentTask.MovedFileSize += currentBlockSize; + CurrentTask.MovedFileSize += currentBlockSize; + } } + + NewFile.LastWriteTime = CurrentFile.LastWriteTime; + NewFile.LastAccessTime = CurrentFile.LastAccessTime; + NewFile.CreationTime = CurrentFile.CreationTime; } + } + else + CurrentTask.MovedFileSize += NewFile.Length; - NewFile.LastWriteTime = CurrentFile.LastWriteTime; - NewFile.LastAccessTime = CurrentFile.LastAccessTime; - NewFile.CreationTime = CurrentFile.CreationTime; + CopiedFiles.Add(NewFile.FullName); + + if (CurrentTask.ReportFileMovement) + { + LogToTM($"[{AppName}] File moved: {NewFile.FullName}"); } + + Functions.Logger.LogToFile(Functions.Logger.LogType.App, $"File moved: {NewFile.FullName}", this); } - else - CurrentTask.MovedFileSize += NewFile.Length; + catch (IOException ioex) + { + CurrentTask.ErrorHappened = true; + Framework.TaskManager.Stop(); + CurrentTask.Active = false; + CurrentTask.Completed = true; - CopiedFiles.Add(NewFile.FullName); + await Main.FormAccessor.AppPanel.Dispatcher.Invoke(async delegate + { + if (await Main.FormAccessor.ShowMessageAsync("Remove moved files?", $"[{AppName}] An error releated to file system is happened while moving files.\n\nError: {ioex.Message}.\n\nWould you like to remove files that already moved from target library?", MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative) + { + Functions.FileSystem.RemoveGivenFiles(CopiedFiles, CreatedDirectories, CurrentTask); + } + }, System.Windows.Threading.DispatcherPriority.Normal); - if (CurrentTask.ReportFileMovement) - { - LogToTM($"[{AppName}] File moved: {NewFile.FullName}"); + + Main.FormAccessor.TaskManager_Logs.Add($"[{AppName}] An error releated to file system is happened while moving files. Error: {ioex.Message}."); + Functions.Logger.LogToFile(Functions.Logger.LogType.SLM, $"[{AppName}][{AppID}][{AcfName}] {ioex}"); + + await SLM.RavenClient.CaptureAsync(new SharpRaven.Data.SentryEvent(ioex)); } + catch (UnauthorizedAccessException uaex) + { + await Main.FormAccessor.AppPanel.Dispatcher.Invoke(async delegate + { + if (await Main.FormAccessor.ShowMessageAsync("Remove moved files?", $"[{AppName}] An error releated to file permissions happened during file movement. Running SLM as Administrator might help.\n\nError: {uaex.Message}.\n\nWould you like to remove files that already moved from target library?", MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative) + { + Functions.FileSystem.RemoveGivenFiles(CopiedFiles, CreatedDirectories, CurrentTask); + } + }, System.Windows.Threading.DispatcherPriority.Normal); - Functions.Logger.LogToFile(Functions.Logger.LogType.App, $"File moved: {NewFile.FullName}", this); + } }); POptions.MaxDegreeOfParallelism = -1; - Parallel.ForEach(AppFiles.Where(x => (x as FileInfo).Length <= Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), POptions, CurrentFile => + Parallel.ForEach(AppFiles.Where(x => (x as FileInfo).Length <= Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), POptions, async CurrentFile => { - FileInfo NewFile = new FileInfo(CurrentFile.FullName.Replace(Library.Steam.SteamAppsFolder.FullName, CurrentTask.TargetLibrary.Steam.SteamAppsFolder.FullName)); - - if (!NewFile.Exists || (NewFile.Length != ((FileInfo)CurrentFile).Length || NewFile.LastWriteTime != ((FileInfo)CurrentFile).LastWriteTime)) + try { - if (!NewFile.Directory.Exists) - { - NewFile.Directory.Create(); - CreatedDirectories.Add(NewFile.Directory.FullName); - } - - int currentBlockSize = 0; - byte[] FSBuffer = new byte[8192]; + FileInfo NewFile = new FileInfo(CurrentFile.FullName.Replace(Library.Steam.SteamAppsFolder.FullName, CurrentTask.TargetLibrary.Steam.SteamAppsFolder.FullName)); - using (FileStream CurrentFileContent = ((FileInfo)CurrentFile).Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + if (!NewFile.Exists || (NewFile.Length != ((FileInfo)CurrentFile).Length || NewFile.LastWriteTime != ((FileInfo)CurrentFile).LastWriteTime)) { - using (FileStream NewFileContent = NewFile.OpenWrite()) + if (!NewFile.Directory.Exists) { - CurrentTask.TaskStatusInfo = $"Copying: {CurrentFile.Name} ({Functions.FileSystem.FormatBytes(((FileInfo)CurrentFile).Length)})"; + NewFile.Directory.Create(); + CreatedDirectories.Add(NewFile.Directory.FullName); + } - while ((currentBlockSize = CurrentFileContent.Read(FSBuffer, 0, FSBuffer.Length)) > 0) + int currentBlockSize = 0; + byte[] FSBuffer = new byte[8192]; + + using (FileStream CurrentFileContent = ((FileInfo)CurrentFile).Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + using (FileStream NewFileContent = NewFile.OpenWrite()) { - if (cancellationToken.IsCancellationRequested) - throw (new OperationCanceledException(cancellationToken)); + CurrentTask.TaskStatusInfo = $"Copying: {CurrentFile.Name} ({Functions.FileSystem.FormatBytes(((FileInfo)CurrentFile).Length)})"; - while (Framework.TaskManager.Paused) + while ((currentBlockSize = CurrentFileContent.Read(FSBuffer, 0, FSBuffer.Length)) > 0) { - Task.Delay(100); - } + if (cancellationToken.IsCancellationRequested) + throw (new OperationCanceledException(cancellationToken)); - NewFileContent.Write(FSBuffer, 0, currentBlockSize); + while (Framework.TaskManager.Paused) + { + Task.Delay(100); + } - CurrentTask.MovedFileSize += currentBlockSize; + NewFileContent.Write(FSBuffer, 0, currentBlockSize); + + CurrentTask.MovedFileSize += currentBlockSize; + } } + + NewFile.LastWriteTime = CurrentFile.LastWriteTime; + NewFile.LastAccessTime = CurrentFile.LastAccessTime; + NewFile.CreationTime = CurrentFile.CreationTime; } + } + else + CurrentTask.MovedFileSize += NewFile.Length; + + CopiedFiles.Add(NewFile.FullName); - NewFile.LastWriteTime = CurrentFile.LastWriteTime; - NewFile.LastAccessTime = CurrentFile.LastAccessTime; - NewFile.CreationTime = CurrentFile.CreationTime; + if (CurrentTask.ReportFileMovement) + { + LogToTM($"[{AppName}] File moved: {NewFile.FullName}"); } + + Functions.Logger.LogToFile(Functions.Logger.LogType.App, $"File moved: {NewFile.FullName}", this); } - else - CurrentTask.MovedFileSize += NewFile.Length; + catch (IOException ioex) + { + CurrentTask.ErrorHappened = true; + Framework.TaskManager.Stop(); + CurrentTask.Active = false; + CurrentTask.Completed = true; - CopiedFiles.Add(NewFile.FullName); + await Main.FormAccessor.AppPanel.Dispatcher.Invoke(async delegate + { + if (await Main.FormAccessor.ShowMessageAsync("Remove moved files?", $"[{AppName}] An error releated to file system is happened while moving files.\n\nError: {ioex.Message}.\n\nWould you like to remove files that already moved from target library?", MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative) + { + Functions.FileSystem.RemoveGivenFiles(CopiedFiles, CreatedDirectories, CurrentTask); + } + }, System.Windows.Threading.DispatcherPriority.Normal); - if (CurrentTask.ReportFileMovement) - { - LogToTM($"[{AppName}] File moved: {NewFile.FullName}"); + + Main.FormAccessor.TaskManager_Logs.Add($"[{AppName}] An error releated to file system is happened while moving files. Error: {ioex.Message}."); + Functions.Logger.LogToFile(Functions.Logger.LogType.SLM, $"[{AppName}][{AppID}][{AcfName}] {ioex}"); + + await SLM.RavenClient.CaptureAsync(new SharpRaven.Data.SentryEvent(ioex)); } + catch (UnauthorizedAccessException uaex) + { + await Main.FormAccessor.AppPanel.Dispatcher.Invoke(async delegate + { + if (await Main.FormAccessor.ShowMessageAsync("Remove moved files?", $"[{AppName}] An error releated to file permissions happened during file movement. Running SLM as Administrator might help.\n\nError: {uaex.Message}.\n\nWould you like to remove files that already moved from target library?", MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative) + { + Functions.FileSystem.RemoveGivenFiles(CopiedFiles, CreatedDirectories, CurrentTask); + } + }, System.Windows.Threading.DispatcherPriority.Normal); - Functions.Logger.LogToFile(Functions.Logger.LogType.App, $"File moved: {NewFile.FullName}", this); + } }); } @@ -443,38 +513,6 @@ public async void CopyFilesAsync(List.TaskInfo CurrentTask, CancellationToken ca LogToTM($"[{AppName}] Time elapsed: {CurrentTask.ElapsedTime.Elapsed} - Average speed: {Math.Round(((TotalFileSize / 1024f) / 1024f) / CurrentTask.ElapsedTime.Elapsed.TotalSeconds, 3)} MB/sec - Average file size: {Functions.FileSystem.FormatBytes(TotalFileSize / (long)CurrentTask.TotalFileCount)}"); Functions.Logger.LogToFile(Functions.Logger.LogType.App, $"Movement completed in {CurrentTask.ElapsedTime.Elapsed} with Average Speed of {Math.Round(((TotalFileSize / 1024f) / 1024f) / CurrentTask.ElapsedTime.Elapsed.TotalSeconds, 3)} MB/sec - Average file size: {Functions.FileSystem.FormatBytes(TotalFileSize / (long)CurrentTask.TotalFileCount)}", this); } - catch (IOException ioex) - { - CurrentTask.ErrorHappened = true; - Framework.TaskManager.Stop(); - CurrentTask.Active = false; - CurrentTask.Completed = true; - - await Main.FormAccessor.AppPanel.Dispatcher.Invoke(async delegate - { - if (await Main.FormAccessor.ShowMessageAsync("Remove moved files?", $"[{AppName}] An error releated to file system is happened while moving files.\n\nError: {ioex.Message}.\n\nWould you like to remove files that already moved from target library?", MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative) - { - Functions.FileSystem.RemoveGivenFiles(CopiedFiles, CreatedDirectories, CurrentTask); - } - }, System.Windows.Threading.DispatcherPriority.Normal); - - - Main.FormAccessor.TaskManager_Logs.Add($"[{AppName}] An error releated to file system is happened while moving files. Error: {ioex.Message}."); - Functions.Logger.LogToFile(Functions.Logger.LogType.SLM, $"[{AppName}][{AppID}][{AcfName}] {ioex}"); - - await SLM.RavenClient.CaptureAsync(new SharpRaven.Data.SentryEvent(ioex)); - } - catch (UnauthorizedAccessException uaex) - { - await Main.FormAccessor.AppPanel.Dispatcher.Invoke(async delegate - { - if (await Main.FormAccessor.ShowMessageAsync("Remove moved files?", $"[{AppName}] An error releated to file permissions happened during file movement. Running SLM as Administrator might help.\n\nError: {uaex.Message}.\n\nWould you like to remove files that already moved from target library?", MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative) - { - Functions.FileSystem.RemoveGivenFiles(CopiedFiles, CreatedDirectories, CurrentTask); - } - }, System.Windows.Threading.DispatcherPriority.Normal); - - } catch (OperationCanceledException) { if (!CurrentTask.ErrorHappened) @@ -546,23 +584,34 @@ public async Task DeleteFilesAsync(List.TaskInfo CurrentTask = null) { Parallel.ForEach(GetFileList(), currentFile => { - currentFile.Refresh(); - - if (currentFile.Exists) + try { - if (CurrentTask != null) + currentFile.Refresh(); + + if (currentFile.Exists) { - while (Framework.TaskManager.Paused) + if (CurrentTask != null) { - Task.Delay(100); + while (Framework.TaskManager.Paused) + { + Task.Delay(100); + } + + CurrentTask.TaskStatusInfo = $"Deleting: {currentFile.Name} ({Functions.FileSystem.FormatBytes(((FileInfo)currentFile).Length)})"; + Main.FormAccessor.TaskManager_Logs.Add($"[{DateTime.Now}] [{CurrentTask.App.AppName}] Deleting file: {currentFile.FullName}"); } - CurrentTask.TaskStatusInfo = $"Deleting: {currentFile.Name} ({Functions.FileSystem.FormatBytes(((FileInfo)currentFile).Length)})"; - Main.FormAccessor.TaskManager_Logs.Add($"[{DateTime.Now}] [{CurrentTask.App.AppName}] Deleting file: {currentFile.FullName}"); + File.SetAttributes(currentFile.FullName, FileAttributes.Normal); + currentFile.Delete(); } - - File.SetAttributes(currentFile.FullName, FileAttributes.Normal); - currentFile.Delete(); + } + catch (FileNotFoundException ex) + { + Functions.Logger.LogToFile(Functions.Logger.LogType.SLM, $"[{AppName}][{AppID}][{AcfName}] {ex}"); + } + catch (UnauthorizedAccessException ex) + { + Functions.Logger.LogToFile(Functions.Logger.LogType.SLM, $"[{AppName}][{AppID}][{AcfName}] {ex}"); } } ); diff --git a/Source/Steam Library Manager/Definitions/Library.cs b/Source/Steam Library Manager/Definitions/Library.cs index d4eeff6a..ef3df684 100644 --- a/Source/Steam Library Manager/Definitions/Library.cs +++ b/Source/Steam Library Manager/Definitions/Library.cs @@ -97,12 +97,12 @@ public void ParseMenuItemAction(string Action) } } - public long FreeSpace => DirectoryInfo.Exists ? Functions.FileSystem.GetAvailableFreeSpace(DirectoryInfo.FullName) : 0; + public long FreeSpace => DirectoryInfo.Exists && !DirectoryInfo.FullName.StartsWith(System.IO.Path.DirectorySeparatorChar.ToString()) ? Functions.FileSystem.GetAvailableFreeSpace(DirectoryInfo.FullName) : 0; - public long TotalSize => DirectoryInfo.Exists ? Functions.FileSystem.GetAvailableTotalSpace(DirectoryInfo.FullName) : 0; + public long TotalSize => DirectoryInfo.Exists && !DirectoryInfo.FullName.StartsWith(System.IO.Path.DirectorySeparatorChar.ToString()) ? Functions.FileSystem.GetAvailableTotalSpace(DirectoryInfo.FullName) : 0; - public string PrettyFreeSpace => DirectoryInfo.Exists ? $"{Functions.FileSystem.FormatBytes(FreeSpace)} / {Functions.FileSystem.FormatBytes(TotalSize)}" : ""; + public string PrettyFreeSpace => DirectoryInfo.Exists && !DirectoryInfo.FullName.StartsWith(System.IO.Path.DirectorySeparatorChar.ToString()) ? $"{Functions.FileSystem.FormatBytes(FreeSpace)} / {Functions.FileSystem.FormatBytes(TotalSize)}" : ""; - public int FreeSpacePerc => DirectoryInfo.Exists ? 100 - ((int)Math.Round((double)(100 * FreeSpace) / Functions.FileSystem.GetAvailableTotalSpace(DirectoryInfo.FullName))) : 0; + public int FreeSpacePerc => DirectoryInfo.Exists && !DirectoryInfo.FullName.StartsWith(System.IO.Path.DirectorySeparatorChar.ToString()) ? 100 - ((int)Math.Round((double)(100 * FreeSpace) / Functions.FileSystem.GetAvailableTotalSpace(DirectoryInfo.FullName))) : 0; } } diff --git a/Source/Steam Library Manager/Definitions/SteamLibrary.cs b/Source/Steam Library Manager/Definitions/SteamLibrary.cs index 43039ce2..9d3f221e 100644 --- a/Source/Steam Library Manager/Definitions/SteamLibrary.cs +++ b/Source/Steam Library Manager/Definitions/SteamLibrary.cs @@ -58,7 +58,7 @@ public void UpdateAppList() } // Foreach *.acf file found in library - Parallel.ForEach(SteamAppsFolder.EnumerateFiles("appmanifest_*.acf", SearchOption.TopDirectoryOnly), AcfFile => + Parallel.ForEach(SteamAppsFolder.EnumerateFiles("appmanifest_*.acf", SearchOption.TopDirectoryOnly).ToList(), AcfFile => { // Define a new value and call KeyValue Framework.KeyValue KeyValReader = new Framework.KeyValue(); @@ -83,14 +83,15 @@ public void UpdateAppList() }); // Do a loop for each *.zip file in library - Parallel.ForEach(Directory.EnumerateFiles(SteamAppsFolder.FullName, "*.zip", SearchOption.TopDirectoryOnly), ArchiveFile => + Parallel.ForEach(Directory.EnumerateFiles(SteamAppsFolder.FullName, "*.zip", SearchOption.TopDirectoryOnly).ToList(), ArchiveFile => { Functions.App.ReadDetailsFromZip(ArchiveFile, Library); }); + SteamBackupsFolder.Refresh(); if (Library.Type == Enums.LibraryType.SLM && SteamBackupsFolder.Exists) { - foreach (FileInfo SkuFile in SteamBackupsFolder.EnumerateFiles("*.sis", SearchOption.AllDirectories)) + foreach (FileInfo SkuFile in SteamBackupsFolder.EnumerateFiles("*.sis", SearchOption.AllDirectories).ToList()) { Framework.KeyValue KeyValReader = new Framework.KeyValue(); @@ -497,7 +498,7 @@ public void UpdateJunks() { if (CommonFolder.Exists) { - foreach (DirectoryInfo DirInfo in CommonFolder.GetDirectories().Where( + foreach (DirectoryInfo DirInfo in CommonFolder.GetDirectories().ToList().Where( x => Apps.Count(y => y.InstallationPath.Name.ToLowerInvariant() == x.Name.ToLowerInvariant()) == 0 && x.Name != "241100" // Steam controller configs && Framework.TaskManager.TaskList.Count( @@ -523,11 +524,11 @@ public void UpdateJunks() if (WorkshopFolder.Exists) { - foreach (FileInfo FileDetails in WorkshopFolder.EnumerateFiles("*.acf", SearchOption.TopDirectoryOnly).Where( + foreach (FileInfo FileDetails in WorkshopFolder.EnumerateFiles("appworkshop_*.acf", SearchOption.TopDirectoryOnly).ToList().Where( x => Apps.Count(y => x.Name == y.WorkShopAcfName) == 0 && x.Name.ToLowerInvariant() != "appworkshop_241100.acf" // Steam Controller Configs && Framework.TaskManager.TaskList.Count( - z => z.App.WorkShopPath.Name.ToLowerInvariant() == x.Name.ToLowerInvariant() + z => z.App.WorkShopAcfName.ToLowerInvariant() == x.Name.ToLowerInvariant() && z.TargetLibrary == Library ) == 0 )) @@ -548,9 +549,13 @@ public void UpdateJunks() if (Directory.Exists(Path.Combine(WorkshopFolder.FullName, "content"))) { - foreach (DirectoryInfo DirInfo in new DirectoryInfo(Path.Combine(WorkshopFolder.FullName, "content")).GetDirectories().Where( + foreach (DirectoryInfo DirInfo in new DirectoryInfo(Path.Combine(WorkshopFolder.FullName, "content")).GetDirectories().ToList().Where( x => Apps.Count(y => y.AppID.ToString() == x.Name) == 0 && x.Name != "241100" // Steam controller configs + && Framework.TaskManager.TaskList.Count( + z => z.App.WorkShopPath.Name.ToLowerInvariant() == x.Name.ToLowerInvariant() + && z.TargetLibrary == Library + ) == 0 ).OrderByDescending(x => Functions.FileSystem.GetDirectorySize(x, true))) { List.JunkInfo Junk = new List.JunkInfo @@ -570,7 +575,7 @@ public void UpdateJunks() if (Directory.Exists(Path.Combine(WorkshopFolder.FullName, "downloads"))) { - foreach (FileInfo FileDetails in new DirectoryInfo(Path.Combine(WorkshopFolder.FullName, "downloads")).EnumerateFiles("*.patch", SearchOption.TopDirectoryOnly).Where( + foreach (FileInfo FileDetails in new DirectoryInfo(Path.Combine(WorkshopFolder.FullName, "downloads")).EnumerateFiles("*.patch", SearchOption.TopDirectoryOnly).ToList().Where( x => Apps.Count(y => x.Name.Contains($"state_{y.AppID}_")) == 0 )) { diff --git a/Source/Steam Library Manager/Forms/Main.xaml.cs b/Source/Steam Library Manager/Forms/Main.xaml.cs index 8af93663..aab0e80c 100644 --- a/Source/Steam Library Manager/Forms/Main.xaml.cs +++ b/Source/Steam Library Manager/Forms/Main.xaml.cs @@ -33,7 +33,6 @@ private void UpdateBindings() { try { - Debug.WriteLine(Functions.SLM.Get45PlusFromRegistry()); Definitions.SLM.RavenClient.Release = Definitions.Updater.CurrentVersion.ToString(); FormAccessor = this; Properties.Settings.Default.SearchText = ""; @@ -549,9 +548,12 @@ private void Grid_MouseDown(object sender, MouseButtonEventArgs e) } else if (((sender as Grid).DataContext is Definitions.Library)) { - if (((sender as Grid).DataContext as Definitions.Library).Steam.SteamAppsFolder.Exists) + if (((sender as Grid).DataContext as Definitions.Library).Steam != null) { - Process.Start(((sender as Grid).DataContext as Definitions.Library).Steam.SteamAppsFolder.FullName); + if (((sender as Grid).DataContext as Definitions.Library).Steam.SteamAppsFolder.Exists) + { + Process.Start(((sender as Grid).DataContext as Definitions.Library).Steam.SteamAppsFolder.FullName); + } } } else if (((sender as Grid).DataContext is Definitions.List.JunkInfo)) @@ -566,7 +568,6 @@ private void Grid_MouseDown(object sender, MouseButtonEventArgs e) catch (Exception ex) { Functions.Logger.LogToFile(Functions.Logger.LogType.SLM, ex.ToString()); - Definitions.SLM.RavenClient.Capture(new SharpRaven.Data.SentryEvent(ex)); } } diff --git a/Source/Steam Library Manager/Functions/SLM.cs b/Source/Steam Library Manager/Functions/SLM.cs index 5f3f8e54..f3fdf012 100644 --- a/Source/Steam Library Manager/Functions/SLM.cs +++ b/Source/Steam Library Manager/Functions/SLM.cs @@ -70,20 +70,27 @@ public static void SaveSettings() public static void OnLoad() { - if (bool.Parse(Properties.Settings.Default.CheckforUpdatesAtStartup)) + try { - Updater.CheckForUpdates(); - } + if (bool.Parse(Properties.Settings.Default.CheckforUpdatesAtStartup)) + { + Updater.CheckForUpdates(); + } - LoadSteam(); - //LoadOrigin(); + LoadSteam(); + //LoadOrigin(); - // SLM Libraries - Library.GenerateLibraryList(); + // SLM Libraries + Library.GenerateLibraryList(); - if (Properties.Settings.Default.ParallelAfterSize >= 20000000) + if (Properties.Settings.Default.ParallelAfterSize >= 20000000) + { + Properties.Settings.Default.ParallelAfterSize = Properties.Settings.Default.ParallelAfterSize / 1000000; + } + } + catch (Exception ex) { - Properties.Settings.Default.ParallelAfterSize = Properties.Settings.Default.ParallelAfterSize / 1000000; + Logger.LogToFile(Logger.LogType.Library, ex.ToString()); } } @@ -153,13 +160,16 @@ public static void GenerateLibraryList() try { // If we have a backup library(s) - if (Properties.Settings.Default.backupDirectories != null && Properties.Settings.Default.backupDirectories.Count > 0) + if (Properties.Settings.Default.backupDirectories == null) + return; + if (Properties.Settings.Default.backupDirectories.Count == 0) + return; + + // for each backup library we have, do a loop + foreach (string BackupPath in Properties.Settings.Default.backupDirectories) { - // for each backup library we have do a loop - foreach (string BackupPath in Properties.Settings.Default.backupDirectories) - { + if (!string.IsNullOrEmpty(BackupPath)) AddNewAsync(BackupPath); - } } } catch (Exception ex) diff --git a/Source/Steam Library Manager/Functions/Steam.cs b/Source/Steam Library Manager/Functions/Steam.cs index 1b02a464..0c2dee5e 100644 --- a/Source/Steam Library Manager/Functions/Steam.cs +++ b/Source/Steam Library Manager/Functions/Steam.cs @@ -464,6 +464,8 @@ public static async void AddNew(string LibraryPath, bool IsMainLibrary = false) catch (Exception ex) { Logger.LogToFile(Logger.LogType.Library, ex.ToString()); + ex.Data.Add("LibraryPath", LibraryPath); + ex.Data.Add("CurrentLibraries", Definitions.List.Libraries); Definitions.SLM.RavenClient.Capture(new SharpRaven.Data.SentryEvent(ex)); } } diff --git a/Source/Steam Library Manager/Properties/AssemblyInfo.cs b/Source/Steam Library Manager/Properties/AssemblyInfo.cs index 36248802..78fa477d 100644 --- a/Source/Steam Library Manager/Properties/AssemblyInfo.cs +++ b/Source/Steam Library Manager/Properties/AssemblyInfo.cs @@ -51,6 +51,6 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.5.0.4")] +[assembly: AssemblyFileVersion("1.5.0.5")] [assembly: NeutralResourcesLanguage("en")]