Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Try to limit situations where we download too many delta's
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Jun 8, 2022
1 parent b3a2eca commit 802efbf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Squirrel/UpdateInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,17 @@ public static UpdateInfo Create(ReleaseEntry currentVersion, IEnumerable<Release

var newerThanUs = availableReleases
.Where(x => x.Version > currentVersion.Version)
.OrderBy(v => v.Version);
.OrderBy(v => v.Version)
.ToArray();

var deltasSize = newerThanUs.Where(x => x.IsDelta).Sum(x => x.Filesize);
var deltasCount = newerThanUs.Count(x => x.IsDelta);

return (deltasSize < latestFull.Filesize && deltasSize > 0) ?
// delta's are cheap to download, but really expensive to apply.
// full packages are more expensive to download, but really cheap to apply.
// this tries to find a good balance of both. we will go for the full if
// there are too many delta's or if their file size is too large.
return (deltasSize > 0 && (deltasSize * 10) < latestFull.Filesize && deltasCount <= 10) ?
new UpdateInfo(currentVersion, newerThanUs.Where(x => x.IsDelta).ToArray(), packageDirectory) :
new UpdateInfo(currentVersion, new[] { latestFull }, packageDirectory);
}
Expand Down

0 comments on commit 802efbf

Please sign in to comment.