C#: a dangling link is an I/O error on read; the directory refusal echoes a header only as store version digits; contract names Rust's real type
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
75ba6c0f5c
commit
425531d88e
5 changed files with 70 additions and 5 deletions
|
|
@ -301,7 +301,7 @@ public static class CultDocumentMessagePackSerialization
|
|||
|
||||
// A store header as a refusal may show it: echoed in the shape cultcache.store.v<digits>, and otherwise described
|
||||
// only by its length, since the bytes are the store's.
|
||||
private static string DescribeHeader(string header)
|
||||
internal static string DescribeHeader(string header)
|
||||
{
|
||||
const string prefix = "cultcache.store.v";
|
||||
var version = header.StartsWith(prefix, StringComparison.Ordinal) ? header.Substring(prefix.Length) : "";
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
|
|||
!string.Equals(snapshot.FormatVersion, IndexedFormatVersionWithIds, StringComparison.Ordinal))
|
||||
{
|
||||
throw new CultStoreUnreadableException(
|
||||
$"Directory store {_manifestFile.FullName} is {snapshot.FormatVersion}; only {IndexedFormatVersion} and {IndexedFormatVersionWithIds} are readable.",
|
||||
$"Directory store {_manifestFile.FullName} is {CultDocumentMessagePackSerialization.DescribeHeader(snapshot.FormatVersion)}; only {IndexedFormatVersion} and {IndexedFormatVersionWithIds} are readable.",
|
||||
_manifestFile.FullName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -302,8 +302,9 @@ and on rewrite alike, because the rewrite asks the same full reader as the open.
|
|||
file and an empty array are an empty store; a zero-byte file is not a store and is refused as unreadable. A flush or a commit replaces a file only when the
|
||||
runtime's own reader opens it, so one verdict covers open, flush and commit, and a file the
|
||||
runtime cannot read is left as it is. Each runtime refuses with one typed error:
|
||||
`CultStoreUnreadableException` (C#), `StoreUnreadableError` (Rust, TypeScript, Python), with
|
||||
the underlying cause attached. Rust, TypeScript and Python also open the legacy envelope
|
||||
`CultStoreUnreadableException` (C#), `CultCacheStoreUnreadable{path, kind}` (Rust, its kind
|
||||
telling an undecodable store from an unsupported format), `StoreUnreadableError` (TypeScript,
|
||||
Python), with the underlying cause attached. Rust, TypeScript and Python also open the legacy envelope
|
||||
array (an array of `key`/`type`/`payload`/`storedAt` maps) and replace it; C# has no legacy
|
||||
reader and refuses it. The shared byte vectors and each runtime's verdict are
|
||||
`tests/vectors/document-variants-c2a/readability/manifest.txt`.
|
||||
|
|
|
|||
|
|
@ -4012,12 +4012,17 @@ namespace GameCult.Caching
|
|||
private byte[]? ReadDisk()
|
||||
{
|
||||
FileInfo.Refresh();
|
||||
if (!FileInfo.Exists)
|
||||
// Only nothing at the path is an empty store. A link whose target is gone is a store that cannot be reached.
|
||||
if (!FileInfo.Exists && FileInfo.LinkTarget == null)
|
||||
return null;
|
||||
try
|
||||
{
|
||||
return ReadAllBytesShared(FileInfo.FullName);
|
||||
}
|
||||
catch (FileNotFoundException ex) when (FileInfo.LinkTarget != null)
|
||||
{
|
||||
throw new IOException("The store path is a link whose target cannot be reached.", ex);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue