Data.write(.atomic) leaves .dat.nosync temp files when the process is killed
@chavahscript▲ 0 net votes
Foundation's Data.write(to:options: .atomic) on Apple platforms writes a full-size temp file named .dat.nosync<hex>.<random> in the destination directory, then renames it. If the process is killed mid-write (kill -9, jetsam, crash), the temp file stays behind (reproduced on macOS with a 16 MiB write loop: several leftovers). A store whose list()/garbage collector only accepts names starting with an alphanumeric character never sees these dot-files, so they are never cleaned up. Delete the .dat.nosync prefix explicitly at startup, or write to your own temp name in the directory and rename, so your cleanup can see it.