Skip to content

Commit 7a1ba55

Browse files
committed
Trigger pending upgrade check after --unmount-all
'gvfs service --unmount-all' sets SkipUnregister on each unmount to preserve automount registration. This meant no UnregisterRepoRequest reached the service, so RequestHandler never called TryDeferredPendingUpgradeCheck and staged upgrades were never applied. Add PendingUpgradeCheckRequest message type. ServiceVerb sends it after the --unmount-all loop completes so the service can schedule the same deferred upgrade check that individual unmounts trigger. Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
1 parent 3c18fe5 commit 7a1ba55

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

GVFS/GVFS.Common/NamedPipes/NamedPipeMessages.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,29 @@ public static Response FromMessage(Message message)
427427
}
428428
}
429429

430+
public class PendingUpgradeCheckRequest
431+
{
432+
public const string Header = nameof(PendingUpgradeCheckRequest);
433+
434+
public static PendingUpgradeCheckRequest FromMessage(Message message)
435+
{
436+
return GVFSJsonOptions.Deserialize<PendingUpgradeCheckRequest>(message.Body);
437+
}
438+
439+
public Message ToMessage()
440+
{
441+
return new Message(Header, GVFSJsonOptions.Serialize(this));
442+
}
443+
444+
public class Response : BaseResponse<PendingUpgradeCheckRequest>
445+
{
446+
public static Response FromMessage(Message message)
447+
{
448+
return GVFSJsonOptions.Deserialize<Response>(message.Body);
449+
}
450+
}
451+
}
452+
430453
public class GetActiveRepoListRequest
431454
{
432455
public const string Header = nameof(GetActiveRepoListRequest);

GVFS/GVFS.Service/Handlers/RequestHandler.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ protected virtual void HandleMessage(
9595

9696
break;
9797

98+
case NamedPipeMessages.PendingUpgradeCheckRequest.Header:
99+
this.requestDescription = "pending upgrade check";
100+
101+
this.TryDeferredPendingUpgradeCheck(this.tracer);
102+
103+
NamedPipeMessages.PendingUpgradeCheckRequest.Response upgradeCheckResponse =
104+
new NamedPipeMessages.PendingUpgradeCheckRequest.Response();
105+
upgradeCheckResponse.State = NamedPipeMessages.CompletionState.Success;
106+
this.TrySendResponse(tracer, upgradeCheckResponse.ToMessage().ToString(), connection);
107+
108+
break;
109+
98110
case NamedPipeMessages.GetActiveRepoListRequest.Header:
99111
this.requestDescription = RepoListRequestDescription;
100112
NamedPipeMessages.GetActiveRepoListRequest repoListRequest = NamedPipeMessages.GetActiveRepoListRequest.FromMessage(message);

GVFS/GVFS/CommandLine/ServiceVerb.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ public override void Execute()
136136
}
137137
}
138138

139+
// Notify the service so it can check for a pending staged
140+
// upgrade. Individual unmounts skip unregister (to preserve
141+
// automount registration), so the service's normal unmount
142+
// trigger never fires during --unmount-all.
143+
this.TryNotifyPendingUpgradeCheck();
144+
139145
if (failedRepoRoots.Count() > 0)
140146
{
141147
string errorString = $"The following repos failed to unmount:{Environment.NewLine}{string.Join(Environment.NewLine, failedRepoRoots.ToArray())}";
@@ -217,5 +223,29 @@ private bool IsRepoMounted(string repoRoot)
217223

218224
return false;
219225
}
226+
227+
private void TryNotifyPendingUpgradeCheck()
228+
{
229+
NamedPipeMessages.PendingUpgradeCheckRequest request = new NamedPipeMessages.PendingUpgradeCheckRequest();
230+
231+
try
232+
{
233+
using (NamedPipeClient client = new NamedPipeClient(this.ServicePipeName))
234+
{
235+
if (!client.Connect())
236+
{
237+
this.Output.WriteLine(" WARNING: Could not notify GVFS.Service to check for pending upgrade (service not responding).");
238+
return;
239+
}
240+
241+
client.SendRequest(request.ToMessage());
242+
NamedPipeMessages.Message response = client.ReadResponse();
243+
}
244+
}
245+
catch (BrokenPipeException)
246+
{
247+
this.Output.WriteLine(" WARNING: Could not notify GVFS.Service to check for pending upgrade.");
248+
}
249+
}
220250
}
221251
}

0 commit comments

Comments
 (0)