ollama - 💡(How to fix) Fix Ollama leaving orphaned files after safetensors import [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#15948Fetched 2026-05-04 04:58:25
View on GitHub
Comments
2
Participants
2
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
commented ×2cross-referenced ×1labeled ×1
RAW_BUFFERClick to expand / collapse

What is the issue?

This issue has been split from #15925 so it can be addressed separately.

Import of safetensors models leaves orphaned files in the blobs directory after conversion to GGUF is complete (success or failure, doesn't matter). Those files take a lot of space and user has no way of knowing which files are not used in order to delete them manually.

I propose using a FILE_FLAG_DELETE_ON_CLOSE when creating those files (at least on Windows, not sure what Linux / Mac equivalent is).

Relevant log output

OS

Windows

GPU

Nvidia

CPU

Intel

Ollama version

0.22.1

extent analysis

TL;DR

Using the FILE_FLAG_DELETE_ON_CLOSE flag when creating files in the blobs directory may prevent orphaned files from accumulating after model conversion.

Guidance

  • Investigate the Windows API for creating files with the FILE_FLAG_DELETE_ON_CLOSE flag to ensure it automatically deletes files when they are closed, regardless of the conversion outcome.
  • Research the equivalent flags or methods for Linux and Mac to ensure cross-platform compatibility.
  • Consider implementing a cleanup mechanism to remove unused files from the blobs directory, in case the flag approach does not cover all scenarios.
  • Verify that using such a flag does not interfere with the normal functioning of the model conversion process.

Example

No example provided due to lack of specific code context.

Notes

The effectiveness of this approach may depend on how the files in the blobs directory are handled and closed after use. Additionally, ensuring the solution works across different operating systems is crucial.

Recommendation

Apply workaround: Using the FILE_FLAG_DELETE_ON_CLOSE flag or its equivalents seems promising for preventing orphaned files, but thorough testing is necessary to confirm its suitability and cross-platform compatibility.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - 💡(How to fix) Fix Ollama leaving orphaned files after safetensors import [2 comments, 2 participants]