Update to 0.4.0.1.

Fix issue with allowing concurrent update.
This commit is contained in:
Captain ALM 2022-09-18 15:16:32 +01:00
parent e3841aa9ec
commit 8d08b0e1a1
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
3 changed files with 22 additions and 17 deletions

View File

@ -81,11 +81,22 @@ namespace com.captainalm.YTDLNetFrontEnd
private void backgroundWorkerMain_DoWork(object sender, DoWorkEventArgs e) private void backgroundWorkerMain_DoWork(object sender, DoWorkEventArgs e)
{ {
setEnableButtons(false);
if (theProcess != null)
{
if (((Control.ModifierKeys & Keys.Shift) == Keys.Shift)) theProcess.kill();
theProcess.waitForExit();
theProcess.close();
}
switch ((BWArg)e.Argument) switch ((BWArg)e.Argument)
{ {
case BWArg.Install: case BWArg.Install:
setEnableButtons(false); this.Invoke(new Action(() =>
{
textBoxOutput.AppendText("Updating YT-DL BackEnd..." + Environment.NewLine);
}));
using (var locpro = using (var locpro =
YTDL.executeInstall((YTDL.getInstalled() != ApplicationType.Unavailable) ? YTDL.getInstalled() : YTDL.executeInstall((YTDL.getInstalled() != ApplicationType.Unavailable) ? YTDL.getInstalled() :
(((Control.ModifierKeys & Keys.Shift) == Keys.Shift) ? ApplicationType.YoutubeDL : ApplicationType.YT_DLP), (((Control.ModifierKeys & Keys.Shift) == Keys.Shift) ? ApplicationType.YoutubeDL : ApplicationType.YT_DLP),
@ -120,15 +131,6 @@ namespace com.captainalm.YTDLNetFrontEnd
setEnableButtons(true); setEnableButtons(true);
break; break;
case BWArg.Go: case BWArg.Go:
setEnableButtons(false);
if (theProcess != null)
{
if (((Control.ModifierKeys & Keys.Shift) == Keys.Shift)) theProcess.kill();
theProcess.waitForExit();
theProcess.close();
}
var theTarget = ""; var theTarget = "";
var extraArgs = ""; var extraArgs = "";

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.4.0.0")] [assembly: AssemblyVersion("0.4.0.1")]
[assembly: AssemblyFileVersion("0.4.0.0")] [assembly: AssemblyFileVersion("0.4.0.1")]

View File

@ -12,6 +12,7 @@ namespace com.captainalm.YTDLNetFrontEnd.util
protected Process representation; protected Process representation;
protected List<IProcessOuputReceiver> outputReceivers = new List<IProcessOuputReceiver>(); protected List<IProcessOuputReceiver> outputReceivers = new List<IProcessOuputReceiver>();
protected List<IProcessOuputReceiver> errorReceivers = new List<IProcessOuputReceiver>(); protected List<IProcessOuputReceiver> errorReceivers = new List<IProcessOuputReceiver>();
protected bool closed = false;
private object inputSLock = new object(); private object inputSLock = new object();
private object outputSLock = new object(); private object outputSLock = new object();
@ -68,7 +69,7 @@ namespace com.captainalm.YTDLNetFrontEnd.util
{ {
lock (processSLock) lock (processSLock)
{ {
if (!startInfo.RedirectStandardInput || representation == null || representation.HasExited) return; if (!startInfo.RedirectStandardInput || representation == null || closed || representation.HasExited) return;
lock (inputSLock) lock (inputSLock)
{ {
representation.StandardInput.Write(inputData); representation.StandardInput.Write(inputData);
@ -78,6 +79,7 @@ namespace com.captainalm.YTDLNetFrontEnd.util
public Process start() public Process start()
{ {
if (closed) return null;
lock (processSLock) lock (processSLock)
{ {
representation = Process.Start(startInfo); representation = Process.Start(startInfo);
@ -128,7 +130,7 @@ namespace com.captainalm.YTDLNetFrontEnd.util
public void waitForExit() public void waitForExit()
{ {
if (representation == null) return; if (representation == null || closed) return;
if (!representation.HasExited) representation.WaitForExit(); if (!representation.HasExited) representation.WaitForExit();
} }
@ -139,7 +141,8 @@ namespace com.captainalm.YTDLNetFrontEnd.util
public void close() public void close()
{ {
if (representation == null) return; if (representation == null || closed) return;
closed = true;
waitForExit(); waitForExit();
if (representation != null && startInfo.RedirectStandardInput) representation.StandardInput.Close(); if (representation != null && startInfo.RedirectStandardInput) representation.StandardInput.Close();
representation.Close(); representation.Close();
@ -147,7 +150,7 @@ namespace com.captainalm.YTDLNetFrontEnd.util
public void kill() public void kill()
{ {
if (representation != null && !representation.HasExited) representation.Kill(); if (representation != null && !closed && !representation.HasExited) representation.Kill();
} }
} }
} }