Skip to content

Commit

Permalink
Merge pull request #58 from textGamex/fix-bug
Browse files Browse the repository at this point in the history
Fix: 无法正常捕获到异常
  • Loading branch information
JusterZhu authored Jul 25, 2024
2 parents 417012f + 1481768 commit c58e980
Showing 1 changed file with 29 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,49 +33,50 @@ public class WindowsStrategy : AbstractStrategy

public override void Execute()
{
try
Task.Run(async () =>
{
Task.Run(async () =>
try
{
var updateVersions = Packet.UpdateVersions.OrderBy(x => x.PubTime).ToList();
if (updateVersions != null && updateVersions.Count > 0)
if (updateVersions.Count > 0)
{
foreach (var version in updateVersions)
{
var patchPath = FileProvider.GetTempDirectory(PATCHS);
var zipFilePath = Path.Combine(Packet.TempPath, $"{version.Name}{Packet.Format}");

var context = new BaseContext.Builder()
.SetVersion(version)
.SetZipfilePath(zipFilePath)
.SetTargetPath(patchPath)
.SetSourcePath(Packet.InstallPath)
.SetFormat(Packet.Format)
.SetEncoding(Packet.Encoding)
.SetBlackFiles(Packet.BlackFiles)
.SetBlackFileFormats(Packet.BlackFormats)
.SetAppType(Packet.AppType)
.Build();

var pipelineBuilder = new PipelineBuilder<BaseContext>(context).
UseMiddleware<HashMiddleware>().
UseMiddleware<ZipMiddleware>().
UseMiddlewareIf<DriveMiddleware>(Packet.DriveEnabled).
UseMiddlewareIf<WillMessageMiddleware>(Packet.WillMessageEnabled).
UseMiddleware<PatchMiddleware>();
.SetVersion(version)
.SetZipfilePath(zipFilePath)
.SetTargetPath(patchPath)
.SetSourcePath(Packet.InstallPath)
.SetFormat(Packet.Format)
.SetEncoding(Packet.Encoding)
.SetBlackFiles(Packet.BlackFiles)
.SetBlackFileFormats(Packet.BlackFormats)
.SetAppType(Packet.AppType)
.Build();

var pipelineBuilder = new PipelineBuilder<BaseContext>(context)
.UseMiddleware<HashMiddleware>().UseMiddleware<ZipMiddleware>()
.UseMiddlewareIf<DriveMiddleware>(Packet.DriveEnabled)
.UseMiddlewareIf<WillMessageMiddleware>(Packet.WillMessageEnabled)
.UseMiddleware<PatchMiddleware>();
await pipelineBuilder.Build();
}
if (!string.IsNullOrEmpty(Packet.UpdateLogUrl)) Process.Start("explorer.exe", Packet.UpdateLogUrl);

if (!string.IsNullOrEmpty(Packet.UpdateLogUrl))
Process.Start("explorer.exe", Packet.UpdateLogUrl);
}

Clear();
StartApp(Packet.AppName, Packet.AppType);
});
}
catch (Exception exception)
{
EventManager.Instance.Dispatch<Action<object, ExceptionEventArgs>>(this, new ExceptionEventArgs(exception));
return;
}
}
catch (Exception e)
{
EventManager.Instance.Dispatch<Action<object, ExceptionEventArgs>>(this, new ExceptionEventArgs(e));
}
});
}

public override bool StartApp(string appName, int appType)
Expand Down

0 comments on commit c58e980

Please sign in to comment.