mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-16 12:16:36 +00:00
* test: cover delete-on-close on the windows mount Windows software creates temporaries with FILE_FLAG_DELETE_ON_CLOSE and never deletes them explicitly. The conformance suite showed a file outliving its last handle — an aborted test left its file behind and every later test hit a name collision — but nothing in this suite asks for the flag, because os offers no way to. Skips where the flag is unavailable rather than passing quietly. * test: fail delete-on-close on a real error instead of skipping Skipping on any error meant a refused flag looked the same as a platform that cannot ask for it, so the test could pass by never running. It now skips only on that one sentinel and reports everything else. Also stops printing a nil error when the file is still there after its last handle closed, and checks the closes it was discarding.
25 lines
712 B
Go
25 lines
712 B
Go
package winfsp
|
|
|
|
import "golang.org/x/sys/windows"
|
|
|
|
// createDeleteOnClose opens a new file that Windows removes when the last
|
|
// handle to it closes. Installers and editors use this for temporaries, and
|
|
// os has no way to ask for it.
|
|
func createDeleteOnClose(path string) (windows.Handle, error) {
|
|
p, err := windows.UTF16PtrFromString(path)
|
|
if err != nil {
|
|
return windows.InvalidHandle, err
|
|
}
|
|
return windows.CreateFile(
|
|
p,
|
|
windows.GENERIC_READ|windows.GENERIC_WRITE,
|
|
windows.FILE_SHARE_READ|windows.FILE_SHARE_WRITE,
|
|
nil,
|
|
windows.CREATE_NEW,
|
|
windows.FILE_ATTRIBUTE_NORMAL|windows.FILE_FLAG_DELETE_ON_CLOSE,
|
|
0,
|
|
)
|
|
}
|
|
|
|
func closeHandle(h windows.Handle) error { return windows.CloseHandle(h) }
|