fix bug on checking hostpath type file

This commit is contained in:
Di Xu 2018-08-31 19:20:20 +08:00
parent 3f5e09b6e2
commit 084fe6de93
2 changed files with 8 additions and 4 deletions

View File

@ -370,7 +370,11 @@ func (ftc *fileTypeChecker) IsFile() bool {
if !ftc.Exists() {
return false
}
return !ftc.IsDir()
pathType, err := ftc.hu.GetFileType(ftc.path)
if err != nil {
return false
}
return string(pathType) == string(v1.HostPathFile)
}
func (ftc *fileTypeChecker) MakeFile() error {

View File

@ -447,7 +447,7 @@ func TestOSFileTypeChecker(t *testing.T) {
if oftc.IsDir() {
t.Errorf("[%d: %q] expected socket file, got unexpected folder: %s", i, tc.name, path)
}
if !oftc.IsFile() {
if oftc.IsFile() {
t.Errorf("[%d: %q] expected socket file, got unexpected file: %s", i, tc.name, path)
}
if oftc.IsBlock() {
@ -465,7 +465,7 @@ func TestOSFileTypeChecker(t *testing.T) {
if oftc.IsDir() {
t.Errorf("[%d: %q] expected character device, got unexpected folder: %s", i, tc.name, path)
}
if !oftc.IsFile() {
if oftc.IsFile() {
t.Errorf("[%d: %q] expected character device, got unexpected file: %s", i, tc.name, path)
}
if oftc.IsSocket() {
@ -483,7 +483,7 @@ func TestOSFileTypeChecker(t *testing.T) {
if oftc.IsDir() {
t.Errorf("[%d: %q] expected block device, got unexpected folder: %s", i, tc.name, path)
}
if !oftc.IsFile() {
if oftc.IsFile() {
t.Errorf("[%d: %q] expected block device, got unexpected file: %s", i, tc.name, path)
}
if oftc.IsSocket() {