startup folder and config folder beeing identical is no longer a supported scenaria

This commit is contained in:
Frank Skare
2019-07-29 22:48:08 +02:00
parent 9c6c0f3506
commit 0f5146e58c
4 changed files with 13 additions and 9 deletions

View File

@@ -13,13 +13,10 @@
- 'Tools > Manage File Associations' was replaced by 'Tools > OS Setup', - '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 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) 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 - 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 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 ### 5.0

View File

@@ -28,7 +28,7 @@ namespace ScriptingExtension // the file name of extensions must end with 'Exten
if (Directory.Exists(mp.ConfigFolder + "scripts")) if (Directory.Exists(mp.ConfigFolder + "scripts"))
scriptFiles.AddRange(Directory.GetFiles(mp.ConfigFolder + "scripts", "*.cs")); 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")) foreach (string file in Directory.GetFiles(PathHelp.StartupPath + "scripts", "*.cs"))
App.UnknownModule(file); App.UnknownModule(file);

View File

@@ -36,7 +36,7 @@ namespace mpvnet
dir = mp.ConfigFolder + "Extensions"; dir = mp.ConfigFolder + "Extensions";
if (Directory.Exists(dir) && mp.ConfigFolder != PathHelp.StartupPath) if (Directory.Exists(dir))
foreach (string i in Directory.GetDirectories(dir)) foreach (string i in Directory.GetDirectories(dir))
catalog.Catalogs.Add(new DirectoryCatalog(i, "*Extension.dll")); catalog.Catalogs.Add(new DirectoryCatalog(i, "*Extension.dll"));

View File

@@ -138,14 +138,14 @@ namespace mpvnet
get { get {
if (_ConfigFolder == null) if (_ConfigFolder == null)
{ {
_ConfigFolder = PathHelp.StartupPath + "portable_config\\"; string portableFolder = PathHelp.StartupPath + "portable_config\\";
_ConfigFolder = portableFolder;
if (!Directory.Exists(_ConfigFolder)) if (!Directory.Exists(_ConfigFolder))
_ConfigFolder = RegHelp.GetString(App.RegPath, "ConfigFolder"); _ConfigFolder = RegHelp.GetString(App.RegPath, "ConfigFolder");
if (!Directory.Exists(_ConfigFolder)) if (!Directory.Exists(_ConfigFolder))
{ {
string portableFolder = PathHelp.StartupPath + "portable_config\\";
string appdataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv.net\\"; string appdataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv.net\\";
string appdataFolderMpv = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\"; string appdataFolderMpv = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\";
@@ -165,6 +165,7 @@ namespace mpvnet
using (var d = new WinForms.FolderBrowserDialog()) using (var d = new WinForms.FolderBrowserDialog())
{ {
d.Description = "Choose a folder."; d.Description = "Choose a folder.";
if (d.ShowDialog() == WinForms.DialogResult.OK) if (d.ShowDialog() == WinForms.DialogResult.OK)
_ConfigFolder = d.SelectedPath + "\\"; _ConfigFolder = d.SelectedPath + "\\";
else 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)) if (!Directory.Exists(_ConfigFolder))
Directory.CreateDirectory(_ConfigFolder); Directory.CreateDirectory(_ConfigFolder);