• Stefy Lanza (nextime / spora )'s avatar
    a failed download must not become a permanent cache hit · 939a1f1c
    Stefy Lanza (nextime / spora ) authored
    download_model wrote straight to its final cache path with no try/except and no
    .partial, and the check guarding it tested existence only. So any interruption
    left a file that was then returned for ever as a valid cached model, and that
    URL could never be fetched again.
    
    Measured in one cache directory on zeiss: 188 zero-byte `<sha256>_<name>.gguf`
    entries accruing about 14 a day since 2026-10-16, against 2 non-empty files. And
    one of those two was a 9.72 GB ltx-2.5-22b-distilled-Q4_K_M.gguf where the real
    file is 13.58 GB — a truncated download the existence-only check would have
    served as a complete model. The empty ones break a load loudly; the truncated one
    loads.
    
    Now: the bytes go to a .partial and are renamed only once they are all there, an
    empty or short transfer raises instead of being kept, and the partial is removed
    on BaseException — not Exception, because a KeyboardInterrupt or SIGTERM
    mid-download is exactly how several of these were made. A zero-byte entry found
    in the cache is treated as a miss and deleted rather than served.
    
    The cache LOCATION is deliberately untouched: moving it would be a silent full
    re-download for every existing install, and a test pins the resolution order.
    Where it points on a given box is a deployment question — on this one a root
    symlink chain (~/.cache/coderai -> /AI/coderai -> /storage/coderai/) aims it at
    the repo's gitignored models/ dir, which is a separate matter from this bug.
    Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_014T3rZozi1Ehk96NG1WesgC
    939a1f1c
__init__.py 4.94 KB