chore: refine error handling for bind mount related issues
Some checks are pending
build / build (push) Waiting to run

This commit is contained in:
Viktor Varland 2025-09-30 12:48:12 +02:00
parent 6cd9860681
commit b35eaa902a
Signed by: varl
GPG key ID: 7459F0B410115EE8

View file

@ -192,12 +192,15 @@ func writeFileAtomic(path string, data []byte) error {
}
if err := osRename(tmp, path); err != nil {
if errors.Is(err, syscall.EBUSY) {
if errors.Is(err, syscall.EBUSY) || errors.Is(err, syscall.ETXTBSY) {
if writeErr := osWriteFile(path, data, 0o644); writeErr != nil {
_ = os.Remove(tmp)
return writeErr
}
return os.Remove(tmp)
if removeErr := os.Remove(tmp); removeErr != nil && !os.IsNotExist(removeErr) {
// best effort cleanup; ignore failure
}
return nil
}
_ = os.Remove(tmp)
return err