cli: classify ssh cache errors in DiskCache

This commit is contained in:
Jon Parise
2026-07-31 16:41:25 -04:00
parent 8fca64957b
commit ca3dc9eeac
2 changed files with 36 additions and 20 deletions

View File

@@ -253,10 +253,9 @@ fn runInner(
if (cache) |c| {
const cached = c.contains(alloc, dest) catch |err| cached: {
// An invalid key is a bad destination, not a bad cache.
if (err != error.InvalidCacheKey) warnPrint(
if (DiskCache.isFailure(err)) warnPrint(
stderr,
"unable to add '{s}' to the cache: {t}",
"unable to read the cache '{s}': {t}",
.{ c.path, err },
);
break :cached false;
@@ -319,23 +318,21 @@ fn runInner(
.real,
).toSeconds())) |_| {
verbosePrint(opts, stderr, "cache: wrote {s}", .{entry.dest});
} else |err| switch (err) {
// An uncacheable destination was already reported above, and a
// lock held by a concurrent `+ssh` resolves itself.
error.InvalidCacheKey,
error.CacheLocked,
=> verbosePrint(
opts,
stderr,
"cache: skipped {s}: {t}",
.{ entry.dest, err },
),
else => warnPrint(
stderr,
"unable to add '{s}' to the cache '{s}': {t}",
.{ entry.dest, entry.cache.path, err },
),
} else |err| {
if (DiskCache.isFailure(err)) {
warnPrint(
stderr,
"unable to add '{s}' to the cache '{s}': {t}",
.{ entry.dest, entry.cache.path, err },
);
} else {
verbosePrint(
opts,
stderr,
"cache: skipped {s}: {t}",
.{ entry.dest, err },
);
}
}
};