Skip to content

Commit a625d2d

Browse files
authored
Delay update notification for one week to ensure all packages become available (PowerShell#27095)
1 parent 45a80d9 commit a625d2d

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ internal static class UpdatesNotification
2828
private const string StableBuildInfoURL = "https://aka.ms/pwsh-buildinfo-stable";
2929
private const string PreviewBuildInfoURL = "https://aka.ms/pwsh-buildinfo-preview";
3030

31+
private const int NotificationDelayDays = 7;
32+
private const int UpdateCheckBackoffDays = 7;
33+
3134
/// <summary>
3235
/// The version of new update is persisted using a file, not as the file content, but instead baked in the file name in the following template:
3336
/// `update{notification-type}_{version}_{publish-date}` -- held by 's_updateFileNameTemplate',
@@ -89,9 +92,18 @@ internal static void ShowUpdateNotification(PSHostUserInterface hostUI)
8992
if (TryParseUpdateFile(
9093
updateFilePath: out _,
9194
out SemanticVersion lastUpdateVersion,
92-
lastUpdateDate: out _)
95+
out DateTime lastUpdateDate)
9396
&& lastUpdateVersion != null)
9497
{
98+
DateTime today = DateTime.UtcNow;
99+
if ((today - lastUpdateDate).TotalDays < NotificationDelayDays)
100+
{
101+
// The update was out less than 1 week ago and it's possible the packages are still rolling out.
102+
// We only show the notification when the update is at least 1 week old, to reduce the chance that
103+
// users see the notification but cannot get the new update when they try to install it.
104+
return;
105+
}
106+
95107
string releaseTag = lastUpdateVersion.ToString();
96108
string notificationMsgTemplate = s_notificationType == NotificationType.LTS
97109
? ManagedEntranceStrings.LTSUpdateNotificationMessage
@@ -169,7 +181,7 @@ internal static async Task CheckForUpdates()
169181
out DateTime lastUpdateDate);
170182

171183
DateTime today = DateTime.UtcNow;
172-
if (parseSuccess && updateFilePath != null && (today - lastUpdateDate).TotalDays < 7)
184+
if (parseSuccess && updateFilePath != null && (today - lastUpdateDate).TotalDays < UpdateCheckBackoffDays)
173185
{
174186
// There is an existing update file, and the last update was less than 1 week ago.
175187
// It's unlikely a new version is released within 1 week, so we can skip this check.

0 commit comments

Comments
 (0)