fix possible race condition
This commit is contained in:
@@ -1276,41 +1276,47 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static object LoadFolderLockObject = new object();
|
||||||
|
|
||||||
public void LoadFolder()
|
public void LoadFolder()
|
||||||
{
|
{
|
||||||
if (!App.AutoLoadFolder || Control.ModifierKeys.HasFlag(Keys.Shift))
|
if (!App.AutoLoadFolder || Control.ModifierKeys.HasFlag(Keys.Shift))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
string path = GetPropertyString("path");
|
|
||||||
|
|
||||||
if (!File.Exists(path) || GetPropertyInt("playlist-count") != 1)
|
lock (LoadFolderLockObject)
|
||||||
return;
|
{
|
||||||
|
string path = GetPropertyString("path");
|
||||||
|
|
||||||
string dir = Environment.CurrentDirectory;
|
if (!File.Exists(path) || GetPropertyInt("playlist-count") != 1)
|
||||||
|
return;
|
||||||
|
|
||||||
if (path.Contains(":/") && !path.Contains("://"))
|
string dir = Environment.CurrentDirectory;
|
||||||
path = path.Replace("/", "\\");
|
|
||||||
|
|
||||||
if (path.Contains("\\"))
|
if (path.Contains(":/") && !path.Contains("://"))
|
||||||
dir = System.IO.Path.GetDirectoryName(path);
|
path = path.Replace("/", "\\");
|
||||||
|
|
||||||
List<string> files = Directory.GetFiles(dir).ToList();
|
if (path.Contains("\\"))
|
||||||
|
dir = System.IO.Path.GetDirectoryName(path);
|
||||||
|
|
||||||
files = files.Where(file =>
|
List<string> files = Directory.GetFiles(dir).ToList();
|
||||||
VideoTypes.Contains(file.Ext()) ||
|
|
||||||
AudioTypes.Contains(file.Ext()) ||
|
|
||||||
ImageTypes.Contains(file.Ext())).ToList();
|
|
||||||
|
|
||||||
files.Sort(new StringLogicalComparer());
|
files = files.Where(file =>
|
||||||
int index = files.IndexOf(path);
|
VideoTypes.Contains(file.Ext()) ||
|
||||||
files.Remove(path);
|
AudioTypes.Contains(file.Ext()) ||
|
||||||
|
ImageTypes.Contains(file.Ext())).ToList();
|
||||||
|
|
||||||
foreach (string i in files)
|
files.Sort(new StringLogicalComparer());
|
||||||
CommandV("loadfile", i, "append");
|
int index = files.IndexOf(path);
|
||||||
|
files.Remove(path);
|
||||||
|
|
||||||
if (index > 0)
|
foreach (string i in files)
|
||||||
CommandV("playlist-move", "0", (index + 1).ToString());
|
CommandV("loadfile", i, "append");
|
||||||
|
|
||||||
|
if (index > 0)
|
||||||
|
CommandV("playlist-move", "0", (index + 1).ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WasAviSynthLoaded;
|
bool WasAviSynthLoaded;
|
||||||
|
|||||||
Reference in New Issue
Block a user