Skip to content

Commit 6202fa8

Browse files
committed
Issue #422 - hardened but I'm not sure the issue is not a misunderstanding.
1 parent 9c2eb9d commit 6202fa8

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

Cognifide.PowerShell/sitecore modules/PowerShell/Services/PowerShellWebService.asmx.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public object ExecuteCommand(string guid, string command, string stringFormat)
105105
var jobOptions = new JobOptions(GetJobId(guid, handle), "PowerShell", "shell", this, "RunJob",
106106
new object[] {session, command})
107107
{
108-
AfterLife = new TimeSpan(0, 10, 0),
108+
AfterLife = new TimeSpan(0, 0, 20),
109109
ContextUser = Sitecore.Context.User,
110110
EnableSecurity = true,
111111
ClientLanguage = Sitecore.Context.ContentLanguage
@@ -123,7 +123,7 @@ public object ExecuteCommand(string guid, string command, string stringFormat)
123123
status = StatusError,
124124
result = output + session.GetExceptionString(ex, ScriptSession.ExceptionStringFormat.Console) + "\r\n" +
125125
"\r\n[[;#f00;#000]Uh oh, looks like the command you ran is invalid or something else went wrong. Is it something we should know about?]\r\n" +
126-
"[[;#f00;#000]Please submit a support ticket here https://git.io/spe/ with error details, screenshots, and anything else that might help.]\r\n\r\n" +
126+
"[[;#f00;#000]Please submit a support ticket here https://git.io/spe with error details, screenshots, and anything else that might help.]\r\n\r\n" +
127127
"[[;#f00;#000]We also have a user guide here http://sitecorepowershell.gitbooks.io/sitecore-powershell-extensions/.]\r\n\r\n",
128128
prompt = string.Format("PS {0}>", session.CurrentLocation)
129129
});
@@ -172,7 +172,7 @@ protected void RunJob(ScriptSession session, string command)
172172
}
173173
job.Status.Messages.Add(exceptionMessage);
174174
job.Status.Messages.Add("Uh oh, looks like the command you ran is invalid or something else went wrong. Is it something we should know about?");
175-
job.Status.Messages.Add("Please submit a support ticket here https://git.io/spe/ with error details, screenshots, and anything else that might help.");
175+
job.Status.Messages.Add("Please submit a support ticket here https://git.io/spe with error details, screenshots, and anything else that might help.");
176176
job.Status.Messages.Add("We also have a user guide here http://sitecorepowershell.gitbooks.io/sitecore-powershell-extensions/.");
177177
}
178178
else
@@ -200,14 +200,21 @@ public object PollCommandOutput(string guid, string handle, string stringFormat)
200200
{
201201
result.status = StatusError;
202202
result.result =
203-
"Can't find your command result. This might mean that your session has timed out or your script caused the application to restart.";
203+
"Can't find your command result. This might mean that your job has timed out or your script caused the application to restart.";
204204
result.prompt = string.Format("PS {0}>", session.CurrentLocation);
205-
session.Output.Clear();
206-
return serializer.Serialize(result);
205+
206+
if (!session.Output.HasUpdates())
207+
{
208+
session.Output.Clear();
209+
return serializer.Serialize(result);
210+
}
211+
}
212+
else
213+
{
214+
result.handle = handle;
207215
}
208216

209-
result.handle = handle;
210-
if (scriptJob.Status.Failed)
217+
if ( scriptJob != null && scriptJob.Status.Failed)
211218
{
212219
result.status = StatusError;
213220
var message =
@@ -220,8 +227,7 @@ public object PollCommandOutput(string guid, string handle, string stringFormat)
220227
return serializer.Serialize(result);
221228
}
222229

223-
var complete = scriptJob.IsDone;
224-
230+
var complete = scriptJob == null || scriptJob.IsDone;
225231

226232
var output = new StringBuilder();
227233
session.Output.GetConsoleUpdate(output, 131072);

0 commit comments

Comments
 (0)