Skip to content

Commit

Permalink
potential memory leak fix
Browse files Browse the repository at this point in the history
  • Loading branch information
laolarou726 committed Dec 2, 2024
1 parent 8bf484d commit bd26b5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,9 @@ ForgeInstallResult GetCorruptedFileResult()
void WhenCompleted(object? sender, DownloadFileCompletedEventArgs e)
{
if (sender is not DownloadFile file) return;
if (!e.Success) this._failedFiles.Add(file);

file.Completed -= this.WhenCompleted;

this._totalDownloaded++;

Expand All @@ -627,7 +630,5 @@ void WhenCompleted(object? sender, DownloadFileCompletedEventArgs e)
this.InvokeStatusChangedEvent(
$"{retryStr}下载 - {file.FileName} ( {this._totalDownloaded} / {this._needToDownload} )",
progress);

if (!e.Success) this._failedFiles.Add(file);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public abstract class ModPackInstallerBase : InstallerBase
protected void WhenCompleted(object? sender, DownloadFileCompletedEventArgs e)
{
if (sender is not DownloadFile file) return;
if (!e.Success) this.FailedFiles.Add(file);

file.Completed -= this.WhenCompleted;

this.TotalDownloaded++;

Expand All @@ -25,7 +28,5 @@ protected void WhenCompleted(object? sender, DownloadFileCompletedEventArgs e)
this.InvokeStatusChangedEvent(
$"{retryStr}下载整合包中的 Mods - {fileName} ({this.TotalDownloaded} / {this.NeedToDownload})",
progress);

if (!e.Success) this.FailedFiles.Add(file);
}
}

0 comments on commit bd26b5f

Please sign in to comment.