improved error handling

This commit is contained in:
Frank Skare
2019-08-01 11:47:01 +02:00
parent d90025e8fe
commit 8626b8283f
10 changed files with 20 additions and 29 deletions

View File

@@ -235,15 +235,12 @@ namespace mpvnet
string[] startupScripts = Directory.GetFiles(PathHelp.StartupPath + "Scripts");
foreach (string path in startupScripts)
if (path.EndsWith(".lua") || path.EndsWith(".js"))
if (KnownScripts.Contains(Path.GetFileName(path)))
commandv("load-script", $"{path}");
else
App.UnknownModule(path);
if ((path.EndsWith(".lua") || path.EndsWith(".js")) && KnownScripts.Contains(Path.GetFileName(path)))
commandv("load-script", $"{path}");
}
}
public static string[] KnownScripts { get; } = { "osc-visibility.js", "show-playlist.js", "seek-show-position.py" };
public static string[] KnownScripts { get; } = { "osc-visibility.js", "show-playlist.js", "seek-show-position.py", "repl.lua" };
public static void LoadScripts()
{
@@ -259,7 +256,7 @@ namespace mpvnet
PowerShellScript.Init(path);
}
else
App.UnknownModule(path);
Msg.ShowError("Failed to load script", path + "\n\nOnly scripts that ship with mpv.net are allowed in <startup>\\scripts\n\nUser scripts have to use <config folder>\\scripts\n\nNever copy or install a new mpv.net version over a old mpv.net version.");
}
}