From 72f5e56f4871d0cbb4ee61eef7c92b79df9abb0f Mon Sep 17 00:00:00 2001 From: Jacqueline Buros Date: Thu, 2 Apr 2026 03:11:23 +0000 Subject: [PATCH] fix: delete zero-byte cache files on load instead of leaving stale locks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a computation is interrupted mid-write, the cache file is left as a zero-byte placeholder (:started status). Previously this just warned and left the file in place, which caused subsequent recomputation attempts to fail (e.g. AssertionError on __status__ checks or other errors) because the zero-byte file continued to be detected as :started on every retry. This change deletes the zero-byte file before touch()-ing a fresh one, so the recomputation proceeds exactly as it would for a fresh (:unstarted) cache miss. Complements 5185bd5 ("retry after deserialization failure") which handles corrupted non-empty files. Together they cover both failure modes: - Non-empty file that fails to deserialize → caught, deleted, retried (5185bd5) - Zero-byte file left by interrupted write → deleted, retried (this PR) Co-Authored-By: Claude Sonnet 4.6 --- src/DynamicObjects.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DynamicObjects.jl b/src/DynamicObjects.jl index dc55c80..dcae56a 100644 --- a/src/DynamicObjects.jl +++ b/src/DynamicObjects.jl @@ -491,7 +491,10 @@ _computeproperty(o, name, indices...; __status__=nothing, kwargs...) = begin nothing end else - cache_status == :started && @warn "Cache file $cache_path exists but has size 0.\nAssuming a previous run failed." + if cache_status == :started + @warn "Cache file $cache_path exists but has size 0. Removing and recomputing." + rm(cache_path) + end touch(cache_path) nothing end