Skip to content

Commit 5dc4f2f

Browse files
committed
AppRepairer: Add ReinstallContent()
1 parent cd68238 commit 5dc4f2f

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

Assets/PatchKit Patcher/Scripts/AppUpdater/AppRepairer.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,9 @@ AppContentSummary latestVersionContentSummary
117117
+ _lowestVersionWithContentId +
118118
" and currently installed version id is "
119119
+ installedVersionId +
120-
". Uninstalling to prepare for content strategy.");
120+
". Reinstalling.");
121121

122-
IUninstallCommand uninstall = _commandFactory.CreateUninstallCommand(Context);
123-
uninstall.Prepare(_status, cancellationToken);
124-
uninstall.Execute(cancellationToken);
122+
ReinstallContent(cancellationToken);
125123
}
126124
else if (repairCost < contentSize)
127125
{
@@ -131,15 +129,8 @@ AppContentSummary latestVersionContentSummary
131129
}
132130
else
133131
{
134-
DebugLogger.Log(string.Format("Content cost {0} is smaller than repair {1}. Uninstalling to prepare for content strategy.", contentSize, repairCost));
135-
IUninstallCommand uninstall = _commandFactory.CreateUninstallCommand(Context);
136-
uninstall.Prepare(_status, cancellationToken);
137-
uninstall.Execute(cancellationToken);
138-
139-
// not catching any exceptions here, because exception during content installation in this place should be fatal
140-
var contentStrategy = new AppUpdaterContentStrategy(Context, _status);
141-
contentStrategy.RepairOnError = false; // do not attempt to repair content to not cause a loop
142-
contentStrategy.Update(cancellationToken);
132+
DebugLogger.Log(string.Format("Content cost {0} is smaller than repair {1}. Reinstalling.", contentSize, repairCost));
133+
ReinstallContent(cancellationToken);
143134
}
144135

145136
return false;
@@ -178,5 +169,17 @@ private long CalculateRepairCost(AppContentSummary contentSummary, IEnumerable<F
178169
.Select(f => contentSummary.Files.FirstOrDefault(e => e.Path == f.FileName))
179170
.Sum(f => f.Size);
180171
}
172+
173+
private void ReinstallContent(PatchKit.Unity.Patcher.Cancellation.CancellationToken cancellationToken)
174+
{
175+
IUninstallCommand uninstall = _commandFactory.CreateUninstallCommand(Context);
176+
uninstall.Prepare(_status, cancellationToken);
177+
uninstall.Execute(cancellationToken);
178+
179+
// not catching any exceptions here, because exception during content installation in this place should be fatal
180+
var contentStrategy = new AppUpdaterContentStrategy(Context, _status);
181+
contentStrategy.RepairOnError = false; // do not attempt to repair content to not cause a loop
182+
contentStrategy.Update(cancellationToken);
183+
}
181184
}
182185
}

0 commit comments

Comments
 (0)