From 1447636eb78276518c023dd1873c588032f27288 Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Wed, 7 Aug 2019 13:16:05 +0200 Subject: [PATCH] fixed race condition causing various features to fail --- Changelog.md | 4 ++++ mpv.net/Misc/App.cs | 4 ++-- mpv.net/Misc/Extension.cs | 2 +- mpv.net/Properties/AssemblyInfo.cs | 4 ++-- mpv.net/mpv/mp.cs | 27 ++++++++++++--------------- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Changelog.md b/Changelog.md index 821b885..3557625 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +### 5.2.1 + +- fixed race condition causing various features to fail + ### 5.2 - bug fix for single-instance not working with unicode filenames diff --git a/mpv.net/Misc/App.cs b/mpv.net/Misc/App.cs index e785bf7..3d4b80e 100644 --- a/mpv.net/Misc/App.cs +++ b/mpv.net/Misc/App.cs @@ -15,7 +15,7 @@ namespace mpvnet public static string[] UrlWhitelist { get; set; } = { "tube", "vimeo", "ard", "zdf" }; public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName; - public static string ConfPath { get; } = mp.ConfigFolder + "\\mpvnet.conf"; + public static string ConfPath { get => mp.ConfigFolder + "mpvnet.conf"; } public static string DarkMode { get; set; } = "always"; public static string ProcessInstance { get; set; } = "single"; public static string DarkColor { get; set; } @@ -49,7 +49,7 @@ namespace mpvnet { try { - string filePath = mp.ConfigFolder + "\\mpvnet-debug.log"; + string filePath = mp.ConfigFolder + "mpvnet-debug.log"; if (File.Exists(filePath)) File.Delete(filePath); Trace.Listeners.Add(new TextWriterTraceListener(filePath)); Trace.AutoFlush = true; diff --git a/mpv.net/Misc/Extension.cs b/mpv.net/Misc/Extension.cs index ad08a78..a954a82 100644 --- a/mpv.net/Misc/Extension.cs +++ b/mpv.net/Misc/Extension.cs @@ -34,7 +34,7 @@ namespace mpvnet } } - dir = mp.ConfigFolder + "Extensions"; + dir = mp.ConfigFolder + "extensions"; if (Directory.Exists(dir)) foreach (string i in Directory.GetDirectories(dir)) diff --git a/mpv.net/Properties/AssemblyInfo.cs b/mpv.net/Properties/AssemblyInfo.cs index cffa402..251844b 100644 --- a/mpv.net/Properties/AssemblyInfo.cs +++ b/mpv.net/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("5.2.0.0")] -[assembly: AssemblyFileVersion("5.2.0.0")] +[assembly: AssemblyVersion("5.2.1.0")] +[assembly: AssemblyFileVersion("5.2.1.0")] diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index 2c8e23b..824e56b 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -70,8 +70,8 @@ namespace mpvnet public static AutoResetEvent ShutdownAutoResetEvent { get; set; } = new AutoResetEvent(false); public static AutoResetEvent VideoSizeAutoResetEvent { get; set; } = new AutoResetEvent(false); - public static string InputConfPath { get; } = ConfigFolder + "\\input.conf"; - public static string ConfPath { get; } = ConfigFolder + "\\mpv.conf"; + public static string InputConfPath { get => ConfigFolder + "input.conf"; } + public static string ConfPath { get => ConfigFolder + "mpv.conf"; } public static string Sid { get; set; } = ""; public static string Aid { get; set; } = ""; public static string Vid { get; set; } = ""; @@ -201,14 +201,14 @@ namespace mpvnet if (!_ConfigFolder.Contains("portable_config")) RegHelp.SetObject(App.RegPath, "ConfigFolder", _ConfigFolder); - if (!File.Exists(_ConfigFolder + "\\input.conf")) - File.WriteAllText(_ConfigFolder + "\\input.conf", Properties.Resources.inputConf); + if (!File.Exists(_ConfigFolder + "input.conf")) + File.WriteAllText(_ConfigFolder + "input.conf", Properties.Resources.inputConf); - if (!File.Exists(_ConfigFolder + "\\mpv.conf")) - File.WriteAllText(_ConfigFolder + "\\mpv.conf", Properties.Resources.mpvConf); + if (!File.Exists(_ConfigFolder + "mpv.conf")) + File.WriteAllText(_ConfigFolder + "mpv.conf", Properties.Resources.mpvConf); - if (!File.Exists(_ConfigFolder + "\\mpvnet.conf")) - File.WriteAllText(_ConfigFolder + "\\mpvnet.conf", Properties.Resources.mpvNetConf); + if (!File.Exists(_ConfigFolder + "mpvnet.conf")) + File.WriteAllText(_ConfigFolder + "mpvnet.conf", Properties.Resources.mpvNetConf); } return _ConfigFolder; } @@ -266,8 +266,8 @@ namespace mpvnet } } - if (Directory.Exists(ConfigFolder + "Scripts")) - foreach (string scriptPath in Directory.GetFiles(ConfigFolder + "Scripts")) + if (Directory.Exists(ConfigFolder + "scripts")) + foreach (string scriptPath in Directory.GetFiles(ConfigFolder + "scripts")) if (scriptPath.EndsWith(".py")) PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); else if (scriptPath.EndsWith(".ps1")) @@ -734,11 +734,8 @@ namespace mpvnet if (File.Exists(LastHistoryPath) && totalMinutes > 1) { - string historyFilepath = ConfigFolder + "history.txt"; - - File.AppendAllText(historyFilepath, DateTime.Now.ToString().Substring(0, 16) + - " " + totalMinutes.ToString().PadLeft(3) + " " + - Path.GetFileNameWithoutExtension(LastHistoryPath) + "\r\n"); + File.AppendAllText(ConfigFolder + "history.txt", DateTime.Now.ToString().Substring(0, 16) + + " " + totalMinutes.ToString().PadLeft(3) + " " + Path.GetFileNameWithoutExtension(LastHistoryPath) + "\r\n"); } LastHistoryPath = path;