Documentation
¶
Overview ¶
Package fsretry retries file system operations that Windows refuses for a short time while another process holds a file open.
Index ¶
Constants ¶
const ( RenameBudget = 10 * time.Second RenameFirstDelay = 25 * time.Millisecond RenameMaxDelay = 500 * time.Millisecond )
Backoff for a transient rename lock: the delay doubles from RenameFirstDelay up to RenameMaxDelay, and the delays sum to RenameBudget. Anti-virus scanners and indexers hold a freshly written or just-started file open for a short, unpredictable time; npm's graceful-fs retries its Windows renames the same way.
Variables ¶
This section is empty.
Functions ¶
func Rename ¶
func Rename(ctx context.Context, oldpath, newpath string, wait func(context.Context, time.Duration) error) error
Rename renames oldpath to newpath and retries a failure TransientRename classifies as a transient lock until the rename succeeds or RenameBudget is spent. wait performs each delay; nil waits on a timer. A failure that is not transient, and the one that exhausts the budget, are returned unchanged. A wait that ctx ends returns the last rename error together with ctx's error.
func TransientRename ¶
TransientRename reports whether a rename failure is a transient lock worth retrying. Unix renames are not subject to the Windows sharing model, so EACCES and EPERM there are real permission failures.
Types ¶
This section is empty.