Documentation
¶
Overview ¶
Package fsutil provides small filesystem helpers shared across packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSharingOrLockViolation ¶
IsSharingOrLockViolation reports whether err is a Windows sharing or lock violation: another open handle on the file denies the requested access. It is always false on other platforms, where the same errno values mean unrelated errors.
func RenameWithRetry ¶
RenameWithRetry renames src to dst, retrying briefly on Windows when the destination is transiently locked (antivirus scanners, search indexers, or a concurrent reader holding the file open). rename overrides os.Rename so tests can exercise the retry path; pass nil to use os.Rename.
func ReplaceWithRetry ¶
ReplaceWithRetry publishes src over dst using the platform's replacement primitive, retrying on the same transient Windows lock errors RenameWithRetry handles. On Windows it uses ReplaceFileW so an existing destination keeps its DACL and selected metadata instead of receiving the temporary file's inherited DACL. ReplaceFileW is not observer-atomic and may briefly leave dst absent; callers that cannot tolerate that must synchronize their own readers. On Unix replacement uses os.Rename.
replace overrides the platform primitive so tests can exercise the retry path; pass nil for the default.
Types ¶
type CommittedReplacementCleanupError ¶
CommittedReplacementCleanupError reports that a replacement was committed, but the old destination retained at BackupPath could not be removed. Callers must treat the replacement itself as successful and surface the cleanup problem separately.
func (*CommittedReplacementCleanupError) Error ¶
func (err *CommittedReplacementCleanupError) Error() string
func (*CommittedReplacementCleanupError) Unwrap ¶
func (err *CommittedReplacementCleanupError) Unwrap() error