Merge pull request #233 from Aireil/add_fallback_failed_disable

Add a fallback when .disabled file creation fails
This commit is contained in:
goaaats 2021-01-05 10:49:53 +01:00 committed by GitHub
commit c14000f672
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -80,8 +80,15 @@ namespace Dalamud.Plugin
// Need to do it with Open so the file handle gets closed immediately
// TODO: Don't use the ".disabled" crap, do it in a config
var disabledFile = File.Open(Path.Combine(outputDir.FullName, ".disabled"), FileMode.Create);
disabledFile.Close();
try {
File.Open(Path.Combine(outputDir.FullName, ".disabled"), FileMode.Create).Close();
} catch (Exception ex) {
Log.Error(ex, "Could not create the .disabled file, disabling all versions...");
foreach (var version in outputDir.Parent.GetDirectories()) {
if (!File.Exists(Path.Combine(version.FullName, ".disabled")))
File.Open(Path.Combine(version.FullName, ".disabled"), FileMode.Create).Close();
}
}
thisPlugin.Plugin.Dispose();