Skip to content

Commit

Permalink
fixed race condition causing various features to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
stax76 committed Aug 7, 2019
1 parent 966f96a commit 1447636
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions mpv.net/Misc/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class App
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; }
Expand Down Expand Up @@ -49,7 +49,7 @@ public static void Init()
{
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;
Expand Down
2 changes: 1 addition & 1 deletion mpv.net/Misc/Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Extension()
}
}

dir = mp.ConfigFolder + "Extensions";
dir = mp.ConfigFolder + "extensions";

if (Directory.Exists(dir))
foreach (string i in Directory.GetDirectories(dir))
Expand Down
4 changes: 2 additions & 2 deletions mpv.net/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 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")]
27 changes: 12 additions & 15 deletions mpv.net/mpv/mp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public class mp
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; } = "";
Expand Down Expand Up @@ -201,14 +201,14 @@ public static string ConfigFolder {
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;
}
Expand Down Expand Up @@ -266,8 +266,8 @@ public static void LoadScripts()
}
}

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"))
Expand Down Expand Up @@ -734,11 +734,8 @@ static void WriteHistory(string path)

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;
Expand Down

0 comments on commit 1447636

Please sign in to comment.