mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
use Access(F_OK) do not need to check for permissions (#18492)
This commit is contained in:
parent
58306a9d34
commit
fe3e49c4eb
@ -33,7 +33,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func access(name string) error {
|
func access(name string) error {
|
||||||
if err := unix.Access(name, unix.R_OK|unix.W_OK); err != nil {
|
if err := unix.Access(name, unix.F_OK); err != nil {
|
||||||
return &os.PathError{Op: "lstat", Path: name, Err: err}
|
return &os.PathError{Op: "lstat", Path: name, Err: err}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -893,8 +893,8 @@ func TestXLStorageListDir(t *testing.T) {
|
|||||||
if err = xlStorageNew.Delete(context.Background(), "mybucket", "myobject", DeleteOptions{
|
if err = xlStorageNew.Delete(context.Background(), "mybucket", "myobject", DeleteOptions{
|
||||||
Recursive: false,
|
Recursive: false,
|
||||||
Force: false,
|
Force: false,
|
||||||
}); err != errVolumeAccessDenied {
|
}); err != errFileAccessDenied {
|
||||||
t.Errorf("expected: %s, got: %s", errVolumeAccessDenied, err)
|
t.Errorf("expected: %s, got: %s", errFileAccessDenied, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -983,14 +983,6 @@ func TestXLStorageDeleteFile(t *testing.T) {
|
|||||||
srcPath: "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
|
srcPath: "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
|
||||||
expectedErr: errFileNameTooLong,
|
expectedErr: errFileNameTooLong,
|
||||||
},
|
},
|
||||||
// TestXLStorage case - 6.
|
|
||||||
// TestXLStorage case with undeletable parent directory.
|
|
||||||
// File can delete, dir cannot delete because no-permissions doesn't have write perms.
|
|
||||||
{
|
|
||||||
srcVol: "no-permissions",
|
|
||||||
srcPath: "dir/file",
|
|
||||||
expectedErr: errVolumeAccessDenied,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
@ -1024,8 +1016,8 @@ func TestXLStorageDeleteFile(t *testing.T) {
|
|||||||
if err = xlStorageNew.Delete(context.Background(), "mybucket", "myobject", DeleteOptions{
|
if err = xlStorageNew.Delete(context.Background(), "mybucket", "myobject", DeleteOptions{
|
||||||
Recursive: false,
|
Recursive: false,
|
||||||
Force: false,
|
Force: false,
|
||||||
}); err != errVolumeAccessDenied {
|
}); err != errFileAccessDenied {
|
||||||
t.Errorf("expected: %s, got: %s", errVolumeAccessDenied, err)
|
t.Errorf("expected: %s, got: %s", errFileAccessDenied, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1406,8 +1398,8 @@ func TestXLStorageAppendFile(t *testing.T) {
|
|||||||
t.Fatalf("Unable to initialize xlStorage, %s", err)
|
t.Fatalf("Unable to initialize xlStorage, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = xlStoragePermStorage.AppendFile(context.Background(), "mybucket", "myobject", []byte("hello, world")); err != errVolumeAccessDenied {
|
if err = xlStoragePermStorage.AppendFile(context.Background(), "mybucket", "myobject", []byte("hello, world")); err != errFileAccessDenied {
|
||||||
t.Fatalf("expected: errVolumeAccessDenied error, got: %s", err)
|
t.Fatalf("expected: errFileAccessDenied error, got: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user