From 0f5146e58ceac55118a53dba72820b16e3ab6460 Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Mon, 29 Jul 2019 22:48:08 +0200 Subject: [PATCH] startup folder and config folder beeing identical is no longer a supported scenaria --- Changelog.md | 7 ++----- extensions/ScriptingExtension/ScriptingExtension.cs | 2 +- mpv.net/Misc/Extension.cs | 2 +- mpv.net/mpv/mp.cs | 11 +++++++++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index 9a6179c..df534d9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -13,13 +13,10 @@ - 'Tools > Manage File Associations' was replaced by 'Tools > OS Setup', it has now a feature to add and remove mpv.net to and from the Path environment variable and the OS default apps settings can be opened (Win 10 only) +- startup folder and config folder beeing identical is no longer + a supported scenaria because it's a brain-dead idea - Error messages are shown when unknown scripts and extensions are found in the startup folder because user scripts and extensions are supposed to be located in the config folder instead -- when the config folder and the startup folder were identical then extensions were loaded - twice and script were loaded four times because the script host is an extension, there is - now a check to ensure extensions and scripts are only loaded once. On first start there - is no longer an option to select the startup folder as config folder, it's still possible - using a custom folder but discouraged ### 5.0 diff --git a/extensions/ScriptingExtension/ScriptingExtension.cs b/extensions/ScriptingExtension/ScriptingExtension.cs index 2982608..b4d38d4 100644 --- a/extensions/ScriptingExtension/ScriptingExtension.cs +++ b/extensions/ScriptingExtension/ScriptingExtension.cs @@ -28,7 +28,7 @@ namespace ScriptingExtension // the file name of extensions must end with 'Exten if (Directory.Exists(mp.ConfigFolder + "scripts")) scriptFiles.AddRange(Directory.GetFiles(mp.ConfigFolder + "scripts", "*.cs")); - if (Directory.Exists(PathHelp.StartupPath + "scripts") && mp.ConfigFolder != PathHelp.StartupPath) + if (Directory.Exists(PathHelp.StartupPath + "scripts")) foreach (string file in Directory.GetFiles(PathHelp.StartupPath + "scripts", "*.cs")) App.UnknownModule(file); diff --git a/mpv.net/Misc/Extension.cs b/mpv.net/Misc/Extension.cs index 299af97..4550e39 100644 --- a/mpv.net/Misc/Extension.cs +++ b/mpv.net/Misc/Extension.cs @@ -36,7 +36,7 @@ namespace mpvnet dir = mp.ConfigFolder + "Extensions"; - if (Directory.Exists(dir) && mp.ConfigFolder != PathHelp.StartupPath) + if (Directory.Exists(dir)) foreach (string i in Directory.GetDirectories(dir)) catalog.Catalogs.Add(new DirectoryCatalog(i, "*Extension.dll")); diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index 5affc17..4e35c27 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -138,14 +138,14 @@ namespace mpvnet get { if (_ConfigFolder == null) { - _ConfigFolder = PathHelp.StartupPath + "portable_config\\"; + string portableFolder = PathHelp.StartupPath + "portable_config\\"; + _ConfigFolder = portableFolder; if (!Directory.Exists(_ConfigFolder)) _ConfigFolder = RegHelp.GetString(App.RegPath, "ConfigFolder"); if (!Directory.Exists(_ConfigFolder)) { - string portableFolder = PathHelp.StartupPath + "portable_config\\"; string appdataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv.net\\"; string appdataFolderMpv = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\"; @@ -165,6 +165,7 @@ namespace mpvnet using (var d = new WinForms.FolderBrowserDialog()) { d.Description = "Choose a folder."; + if (d.ShowDialog() == WinForms.DialogResult.OK) _ConfigFolder = d.SelectedPath + "\\"; else @@ -173,6 +174,12 @@ namespace mpvnet } } + if (PathHelp.StartupPath == _ConfigFolder) + { + Msg.ShowError("Startup folder and config folder cannot be identical, using portable_config instead."); + _ConfigFolder = portableFolder; + } + if (!Directory.Exists(_ConfigFolder)) Directory.CreateDirectory(_ConfigFolder);