mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-20 15:44:22 +01:00
Add a try-catch when scanning for mods.
This commit is contained in:
parent
e21c9fb6d1
commit
792a04337f
1 changed files with 23 additions and 13 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Security.AccessControl;
|
||||||
using Penumbra.Communication;
|
using Penumbra.Communication;
|
||||||
using Penumbra.Mods.Editor;
|
using Penumbra.Mods.Editor;
|
||||||
using Penumbra.Services;
|
using Penumbra.Services;
|
||||||
|
|
@ -311,22 +312,31 @@ public sealed class ModManager : ModStorage, IDisposable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ScanMods()
|
private void ScanMods()
|
||||||
{
|
{
|
||||||
var options = new ParallelOptions()
|
try
|
||||||
{
|
{
|
||||||
MaxDegreeOfParallelism = Math.Max(1, Environment.ProcessorCount / 2),
|
var options = new ParallelOptions()
|
||||||
};
|
{
|
||||||
var queue = new ConcurrentQueue<Mod>();
|
MaxDegreeOfParallelism = Math.Max(1, Environment.ProcessorCount / 2),
|
||||||
Parallel.ForEach(BasePath.EnumerateDirectories(), options, dir =>
|
};
|
||||||
{
|
var queue = new ConcurrentQueue<Mod>();
|
||||||
var mod = Creator.LoadMod(dir, false);
|
Parallel.ForEach(BasePath.EnumerateDirectories(), options, dir =>
|
||||||
if (mod != null)
|
{
|
||||||
queue.Enqueue(mod);
|
var mod = Creator.LoadMod(dir, false);
|
||||||
});
|
if (mod != null)
|
||||||
|
queue.Enqueue(mod);
|
||||||
|
});
|
||||||
|
|
||||||
foreach (var mod in queue)
|
foreach (var mod in queue)
|
||||||
|
{
|
||||||
|
mod.Index = Count;
|
||||||
|
Mods.Add(mod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
mod.Index = Count;
|
Valid = false;
|
||||||
Mods.Add(mod);
|
_communicator.ModDirectoryChanged.Invoke(BasePath.FullName, false);
|
||||||
|
Penumbra.Log.Error($"Could not scan for mods:\n{ex}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue