aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Integrations/Scripts
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-11-08 10:15:14 -0600
committerGitHub <noreply@github.com>2026-11-08 10:15:14 -0600
commit169bb8a3c0098599a617d8553e93c694bd813795 (patch)
tree4d825302717fc76d543b6a24469ad23a605cd5c8 /src/slskd/Integrations/Scripts
parent4eaa2b13e2da250d7b89073a15e9f1e077661fd7 (diff)
parentcefdcd02e28b1f02f546002fdd475de4fa03e839 (diff)
downloadslskd-169bb8a3c0098599a617d8553e93c694bd813795.tar.gz
Merge branch 'master' into dependabot/npm_and_yarn/src/web/follow-redirects-1.16.2
Diffstat (limited to 'src/slskd/Integrations/Scripts')
-rw-r--r--src/slskd/Integrations/Scripts/ScriptService.cs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/slskd/Integrations/Scripts/ScriptService.cs b/src/slskd/Integrations/Scripts/ScriptService.cs
index 33ef0b9b..f3f0efde 100644
--- a/src/slskd/Integrations/Scripts/ScriptService.cs
+++ b/src/slskd/Integrations/Scripts/ScriptService.cs
@@ -108,7 +108,7 @@ public class ScriptService
foreach (var script in scriptsTriggeredByThisEventType)
{
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
Process process = default;
var processId = Guid.NewGuid();
@@ -123,7 +123,7 @@ public class ScriptService
if (string.IsNullOrEmpty(executable))
{
- Log.Warning("Script '{Script}' will not be run: unable to determine script executable. Update the script configuration, or set your operating system's SHELL envar.");
+ Log.Warning("Script '{Script}' will not be run: unable to determine script executable. Update the script configuration, or set your operating system's SHELL envar.", script.Key);
return;
}
@@ -202,17 +202,20 @@ public class ScriptService
process.Start();
- process.WaitForExit();
+ var errorTask = process.StandardError.ReadToEndAsync();
+ var outputTask = process.StandardOutput.ReadToEndAsync();
+
+ await process.WaitForExitAsync();
sw.Stop();
- var error = process.StandardError.ReadToEnd();
+ var error = await errorTask;
if (!string.IsNullOrEmpty(error))
{
throw new Exception($"STDERR: {Regex.Replace(error, @"\r\n?|\n", " ", RegexOptions.Compiled)}");
}
- var result = process.StandardOutput.ReadToEnd();
+ var result = await outputTask;
var resultAsLines = result.Split(["\r\n", "\r", "\n"], StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
Log.Debug("Script '{Script}' ran successfully in {Duration}ms; output: {Output} (id: {ProcessId})", script.Key, sw.ElapsedMilliseconds, resultAsLines, processId);