mirror of
https://github.com/pgsty/minio.git
synced 2026-08-07 08:11:13 +03:00
posix: Deprecate custom removeAll/mkdirAll implementations. (#4808)
Since go1.8 os.RemoveAll and os.MkdirAll both support long path names i.e UNC path on windows. The code we are carrying was directly borrowed from `pkg/os` package and doesn't need to be in our repo anymore. As a side affect this also addresses our codecoverage issue. Refer #4658
This commit is contained in:
committed by
Dee Koder
parent
b69aa9c4d0
commit
d864e00e24
@@ -21,7 +21,6 @@ package cmd
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -105,32 +104,3 @@ func TestUNCPathENOTDIR(t *testing.T) {
|
||||
t.Errorf("expected: %s, got: %s", errFileAccessDenied, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Test to validate 32k path works on windows platform
|
||||
func Test32kUNCPath(t *testing.T) {
|
||||
var err error
|
||||
// The following calculation was derived empirically. It is not exactly MAX_PATH - len(longDiskName)
|
||||
// possibly due to expansion rules as mentioned here -
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath
|
||||
var longPathName string
|
||||
for {
|
||||
compt := strings.Repeat("a", 255)
|
||||
if len(compt)+len(longPathName)+1 > 32767 {
|
||||
break
|
||||
}
|
||||
longPathName = longPathName + `\` + compt
|
||||
}
|
||||
longPathName = "C:" + longPathName
|
||||
err = mkdirAll(longPathName, 0777)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Cleanup on exit of test
|
||||
defer removeAll(longPathName)
|
||||
|
||||
_, err = newPosix(longPathName)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user