mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 04:04:46 +08:00
lib/file: make pre-allocate detect disk full errors and return them
This commit is contained in:
parent
4fbb50422c
commit
40b58d59ad
6
lib/file/preallocate.go
Normal file
6
lib/file/preallocate.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package file
|
||||
|
||||
import "errors"
|
||||
|
||||
// ErrDiskFull is returned from PreAllocate when it detects disk full
|
||||
var ErrDiskFull = errors.New("preallocate: file too big for remaining disk space")
|
|
@ -42,10 +42,10 @@ again:
|
|||
goto again
|
||||
|
||||
}
|
||||
// FIXME could be doing something here
|
||||
// if err == unix.ENOSPC {
|
||||
// log.Printf("No space")
|
||||
// }
|
||||
// Wrap important errors
|
||||
if err == unix.ENOSPC {
|
||||
return ErrDiskFull
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,9 @@ func PreAllocate(size int64, out *os.File) error {
|
|||
uintptr(19), // FileAllocationInformation
|
||||
)
|
||||
if e1 != nil && e1 != syscall.Errno(0) {
|
||||
if e1 == syscall.Errno(windows.ERROR_DISK_FULL) || e1 == syscall.Errno(windows.ERROR_HANDLE_DISK_FULL) {
|
||||
return ErrDiskFull
|
||||
}
|
||||
return errors.Wrap(e1, "preAllocate NtSetInformationFile failed")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user