fix(workspace): a pull that succeeded never fails on the name it follows

The name follow after a pull caught only the home's own exceptions, so a 403
or any other error from the home's list (or a bundle in use) made a pull that
had already pulled and replayed report a failure. It is now logged as a
warning and the name is followed at the next pull; a cancellation still passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-04 13:35:47 +01:00
1 parent ab6cad51b2
commit 5ff9c086fd
3 files changed
+73 -6

No files matched your search

+15 -6
View File
@@ -388,21 +388,30 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
return await FollowNameLockedAsync(project, home, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// <see cref="FollowNameAsync"/> under the project's lock. It runs after a pull that succeeded, so it never fails: whatever
/// the home or the copy answers (unreachable, a refusal such as a 403, a file in use) is logged and the name is followed
/// next time; only a cancellation is passed on.
/// </summary>
private static async Task<bool> FollowNameLockedAsync(WorkspaceProject project, IProjectHome home, CancellationToken cancellationToken)
{
SequenceProject? listed;
try
{
listed = (await home.ListAsync(cancellationToken).ConfigureAwait(false)).FirstOrDefault(p => p.Id == project.ProjectId);
var listed = (await home.ListAsync(cancellationToken).ConfigureAwait(false)).FirstOrDefault(p => p.Id == project.ProjectId);
var bundle = project.ReadBundle();
if (listed is null || bundle.Workspace is not { } workspace || (workspace.Name == listed.Name && workspace.IsMain == listed.IsMain)) return false;
project.WriteBundle(bundle with { Workspace = workspace with { Name = listed.Name, IsMain = listed.IsMain } });
return true;
}
catch (Exception ex) when (ex is HomeUnavailableException or ProjectException)
{
return false;
}
var bundle = project.ReadBundle();
if (listed is null || bundle.Workspace is not { } workspace || (workspace.Name == listed.Name && workspace.IsMain == listed.IsMain)) return false;
project.WriteBundle(bundle with { Workspace = workspace with { Name = listed.Name, IsMain = listed.IsMain } });
return true;
catch (Exception ex) when (ex is not OperationCanceledException || !cancellationToken.IsCancellationRequested)
{
Log.Warning("workspace", $"The name of project {project.ProjectId} could not be followed from its home; tried again at the next pull", ex);
return false;
}
}
/// <summary>