fs stat(): Return dir stat with incomplete flag (#2078)
fs.Stat() returns an error when the path corresponds to a directory and incomplete flag is enabled. This PR follows S3 client behavior and fixes the behavior.
This commit is contained in:
committed by
Harshavardhana
parent
9ebb916902
commit
29920f8c9c
+12
-2
@@ -1203,15 +1203,24 @@ func (f *fsClient) handleWindowsSymlinks(fpath string) (os.FileInfo, *probe.Erro
|
||||
// fsStat - wrapper function to get file stat.
|
||||
func (f *fsClient) fsStat(isIncomplete bool) (os.FileInfo, *probe.Error) {
|
||||
fpath := f.PathURL.Path
|
||||
|
||||
// Check if the path corresponds to a directory and returns
|
||||
// the successful result whether isIncomplete is specified or not.
|
||||
st, e := os.Stat(fpath)
|
||||
if e == nil && st.IsDir() {
|
||||
return st, nil
|
||||
}
|
||||
|
||||
if isIncomplete {
|
||||
fpath += partSuffix
|
||||
}
|
||||
|
||||
// Golang strips trailing / if you clean(..) or
|
||||
// EvalSymlinks(..). Adding '.' prevents it from doing so.
|
||||
if strings.HasSuffix(fpath, string(f.PathURL.Separator)) {
|
||||
fpath = fpath + "."
|
||||
}
|
||||
fpath, e := filepath.EvalSymlinks(fpath)
|
||||
fpath, e = filepath.EvalSymlinks(fpath)
|
||||
if e != nil {
|
||||
if os.IsPermission(e) {
|
||||
if runtime.GOOS == "windows" {
|
||||
@@ -1222,7 +1231,8 @@ func (f *fsClient) fsStat(isIncomplete bool) (os.FileInfo, *probe.Error) {
|
||||
err := f.toClientError(e, f.PathURL.Path)
|
||||
return nil, err.Trace(fpath)
|
||||
}
|
||||
st, e := os.Stat(fpath)
|
||||
|
||||
st, e = os.Stat(fpath)
|
||||
if e != nil {
|
||||
if os.IsPermission(e) {
|
||||
if runtime.GOOS == "windows" {
|
||||
|
||||
Reference in New Issue
Block a user