|
|
@ -121,26 +121,63 @@ func checkDiskFree(diskPath string, minFreeDisk int64) (err error) { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Make a volume entry.
|
|
|
|
// checkVolumeArg - will convert incoming volume names to
|
|
|
|
func (s fsStorage) MakeVol(volume string) (err error) { |
|
|
|
// corresponding valid volume names on the backend in a platform
|
|
|
|
if volume == "" { |
|
|
|
// compatible way for all operating systems. If volume is not found
|
|
|
|
return errInvalidArgument |
|
|
|
// an error is generated.
|
|
|
|
|
|
|
|
func (s fsStorage) checkVolumeArg(volume string) (string, error) { |
|
|
|
|
|
|
|
if !isValidVolname(volume) { |
|
|
|
|
|
|
|
return "", errInvalidArgument |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
volumeDir := filepath.Join(s.diskPath, volume) |
|
|
|
|
|
|
|
_, err := os.Stat(volumeDir) |
|
|
|
|
|
|
|
if err == nil { |
|
|
|
|
|
|
|
return volumeDir, nil |
|
|
|
} |
|
|
|
} |
|
|
|
if err = checkDiskFree(s.diskPath, s.minFreeDisk); err != nil { |
|
|
|
if os.IsNotExist(err) { |
|
|
|
return err |
|
|
|
var volumes []os.FileInfo |
|
|
|
|
|
|
|
volumes, err = ioutil.ReadDir(s.diskPath) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return volumeDir, errVolumeNotFound |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for _, vol := range volumes { |
|
|
|
|
|
|
|
if vol.IsDir() { |
|
|
|
|
|
|
|
// Verify if lowercase version of the volume
|
|
|
|
|
|
|
|
// is equal to the incoming volume, then use the proper name.
|
|
|
|
|
|
|
|
if strings.ToLower(vol.Name()) == volume { |
|
|
|
|
|
|
|
volumeDir = filepath.Join(s.diskPath, vol.Name()) |
|
|
|
|
|
|
|
return volumeDir, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return volumeDir, errVolumeNotFound |
|
|
|
|
|
|
|
} else if os.IsPermission(err) { |
|
|
|
|
|
|
|
return volumeDir, errVolumeAccessDenied |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return volumeDir, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
volumeDir := getVolumeDir(s.diskPath, volume) |
|
|
|
// Make a volume entry.
|
|
|
|
if _, err = os.Stat(volumeDir); err == nil { |
|
|
|
func (s fsStorage) MakeVol(volume string) (err error) { |
|
|
|
|
|
|
|
volumeDir, err := s.checkVolumeArg(volume) |
|
|
|
|
|
|
|
if err == nil { |
|
|
|
|
|
|
|
// Volume already exists, return error.
|
|
|
|
return errVolumeExists |
|
|
|
return errVolumeExists |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Make a volume entry.
|
|
|
|
// Validate if disk is free.
|
|
|
|
if err = os.Mkdir(volumeDir, 0700); err != nil { |
|
|
|
if e := checkDiskFree(s.diskPath, s.minFreeDisk); e != nil { |
|
|
|
return err |
|
|
|
return e |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
// If volume not found create it.
|
|
|
|
|
|
|
|
if err == errVolumeNotFound { |
|
|
|
|
|
|
|
// Make a volume entry.
|
|
|
|
|
|
|
|
return os.Mkdir(volumeDir, 0700) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// For all other errors return here.
|
|
|
|
|
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// removeDuplicateVols - remove duplicate volumes.
|
|
|
|
// removeDuplicateVols - remove duplicate volumes.
|
|
|
@ -175,9 +212,15 @@ func (s fsStorage) ListVols() (volsInfo []VolInfo, err error) { |
|
|
|
// If not directory, ignore all file types.
|
|
|
|
// If not directory, ignore all file types.
|
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Volname on case sensitive fs backends can come in as
|
|
|
|
|
|
|
|
// capitalized, but object layer cannot consume it
|
|
|
|
|
|
|
|
// directly. Convert it as we see fit.
|
|
|
|
|
|
|
|
volName := strings.ToLower(file.Name()) |
|
|
|
|
|
|
|
// Modtime is used as created time.
|
|
|
|
|
|
|
|
createdTime := file.ModTime() |
|
|
|
volInfo := VolInfo{ |
|
|
|
volInfo := VolInfo{ |
|
|
|
Name: file.Name(), |
|
|
|
Name: volName, |
|
|
|
Created: file.ModTime(), |
|
|
|
Created: createdTime, |
|
|
|
} |
|
|
|
} |
|
|
|
volsInfo = append(volsInfo, volInfo) |
|
|
|
volsInfo = append(volsInfo, volInfo) |
|
|
|
} |
|
|
|
} |
|
|
@ -186,30 +229,13 @@ func (s fsStorage) ListVols() (volsInfo []VolInfo, err error) { |
|
|
|
return volsInfo, nil |
|
|
|
return volsInfo, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// getVolumeDir - will convert incoming volume names to
|
|
|
|
|
|
|
|
// corresponding valid volume names on the backend in a platform
|
|
|
|
|
|
|
|
// compatible way for all operating systems.
|
|
|
|
|
|
|
|
func getVolumeDir(diskPath, volume string) string { |
|
|
|
|
|
|
|
volumes, e := ioutil.ReadDir(diskPath) |
|
|
|
|
|
|
|
if e != nil { |
|
|
|
|
|
|
|
return volume |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for _, vol := range volumes { |
|
|
|
|
|
|
|
// Verify if lowercase version of the volume
|
|
|
|
|
|
|
|
// is equal to the incoming volume, then use the proper name.
|
|
|
|
|
|
|
|
if strings.ToLower(vol.Name()) == volume { |
|
|
|
|
|
|
|
return filepath.Join(diskPath, vol.Name()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return filepath.Join(diskPath, volume) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// StatVol - get volume info.
|
|
|
|
// StatVol - get volume info.
|
|
|
|
func (s fsStorage) StatVol(volume string) (volInfo VolInfo, err error) { |
|
|
|
func (s fsStorage) StatVol(volume string) (volInfo VolInfo, err error) { |
|
|
|
if volume == "" { |
|
|
|
// Verify if volume is valid and it exists.
|
|
|
|
return VolInfo{}, errInvalidArgument |
|
|
|
volumeDir, err := s.checkVolumeArg(volume) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return VolInfo{}, err |
|
|
|
} |
|
|
|
} |
|
|
|
volumeDir := getVolumeDir(s.diskPath, volume) |
|
|
|
|
|
|
|
// Stat a volume entry.
|
|
|
|
// Stat a volume entry.
|
|
|
|
var st os.FileInfo |
|
|
|
var st os.FileInfo |
|
|
|
st, err = os.Stat(volumeDir) |
|
|
|
st, err = os.Stat(volumeDir) |
|
|
@ -219,18 +245,23 @@ func (s fsStorage) StatVol(volume string) (volInfo VolInfo, err error) { |
|
|
|
} |
|
|
|
} |
|
|
|
return VolInfo{}, err |
|
|
|
return VolInfo{}, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Modtime is used as created time since operating systems lack a
|
|
|
|
|
|
|
|
// portable way of knowing the actual created time of a directory.
|
|
|
|
|
|
|
|
createdTime := st.ModTime() |
|
|
|
return VolInfo{ |
|
|
|
return VolInfo{ |
|
|
|
Name: st.Name(), |
|
|
|
Name: volume, |
|
|
|
Created: st.ModTime(), |
|
|
|
Created: createdTime, |
|
|
|
}, nil |
|
|
|
}, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// DeleteVol - delete a volume.
|
|
|
|
// DeleteVol - delete a volume.
|
|
|
|
func (s fsStorage) DeleteVol(volume string) error { |
|
|
|
func (s fsStorage) DeleteVol(volume string) error { |
|
|
|
if volume == "" { |
|
|
|
// Verify if volume is valid and it exists.
|
|
|
|
return errInvalidArgument |
|
|
|
volumeDir, err := s.checkVolumeArg(volume) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
err := os.Remove(getVolumeDir(s.diskPath, volume)) |
|
|
|
err = os.Remove(volumeDir) |
|
|
|
if err != nil && os.IsNotExist(err) { |
|
|
|
if err != nil && os.IsNotExist(err) { |
|
|
|
return errVolumeNotFound |
|
|
|
return errVolumeNotFound |
|
|
|
} |
|
|
|
} |
|
|
@ -281,23 +312,13 @@ var specialPrefixes = []string{ |
|
|
|
|
|
|
|
|
|
|
|
// List operation.
|
|
|
|
// List operation.
|
|
|
|
func (s fsStorage) ListFiles(volume, prefix, marker string, recursive bool, count int) ([]FileInfo, bool, error) { |
|
|
|
func (s fsStorage) ListFiles(volume, prefix, marker string, recursive bool, count int) ([]FileInfo, bool, error) { |
|
|
|
if volume == "" { |
|
|
|
// Verify if volume is valid and it exists.
|
|
|
|
return nil, true, errInvalidArgument |
|
|
|
volumeDir, err := s.checkVolumeArg(volume) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, true, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var fileInfos []FileInfo |
|
|
|
var fileInfos []FileInfo |
|
|
|
|
|
|
|
|
|
|
|
volumeDir := getVolumeDir(s.diskPath, volume) |
|
|
|
|
|
|
|
// Verify if volume directory exists
|
|
|
|
|
|
|
|
if exists, err := isDirExist(volumeDir); !exists { |
|
|
|
|
|
|
|
if err == nil { |
|
|
|
|
|
|
|
return nil, true, errVolumeNotFound |
|
|
|
|
|
|
|
} else if os.IsNotExist(err) { |
|
|
|
|
|
|
|
return nil, true, errVolumeNotFound |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return nil, true, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if marker != "" { |
|
|
|
if marker != "" { |
|
|
|
// Verify if marker has prefix.
|
|
|
|
// Verify if marker has prefix.
|
|
|
|
if marker != "" && !strings.HasPrefix(marker, prefix) { |
|
|
|
if marker != "" && !strings.HasPrefix(marker, prefix) { |
|
|
@ -323,6 +344,7 @@ func (s fsStorage) ListFiles(volume, prefix, marker string, recursive bool, coun |
|
|
|
// Prefix does not exist, not an error just respond empty list response.
|
|
|
|
// Prefix does not exist, not an error just respond empty list response.
|
|
|
|
return nil, true, nil |
|
|
|
return nil, true, nil |
|
|
|
} else if strings.Contains(err.Error(), "not a directory") { |
|
|
|
} else if strings.Contains(err.Error(), "not a directory") { |
|
|
|
|
|
|
|
// Prefix exists as a file.
|
|
|
|
return nil, true, nil |
|
|
|
return nil, true, nil |
|
|
|
} |
|
|
|
} |
|
|
|
// Rest errors should be treated as failure.
|
|
|
|
// Rest errors should be treated as failure.
|
|
|
@ -375,26 +397,18 @@ func (s fsStorage) ListFiles(volume, prefix, marker string, recursive bool, coun |
|
|
|
|
|
|
|
|
|
|
|
// ReadFile - read a file at a given offset.
|
|
|
|
// ReadFile - read a file at a given offset.
|
|
|
|
func (s fsStorage) ReadFile(volume string, path string, offset int64) (readCloser io.ReadCloser, err error) { |
|
|
|
func (s fsStorage) ReadFile(volume string, path string, offset int64) (readCloser io.ReadCloser, err error) { |
|
|
|
if volume == "" || path == "" { |
|
|
|
volumeDir, err := s.checkVolumeArg(volume) |
|
|
|
return nil, errInvalidArgument |
|
|
|
if err != nil { |
|
|
|
} |
|
|
|
return nil, err |
|
|
|
volumeDir := getVolumeDir(s.diskPath, volume) |
|
|
|
|
|
|
|
// Verify if volume directory exists
|
|
|
|
|
|
|
|
var exists bool |
|
|
|
|
|
|
|
if exists, err = isDirExist(volumeDir); !exists { |
|
|
|
|
|
|
|
if err == nil { |
|
|
|
|
|
|
|
return nil, errVolumeNotFound |
|
|
|
|
|
|
|
} else if os.IsNotExist(err) { |
|
|
|
|
|
|
|
return nil, errVolumeNotFound |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
filePath := filepath.Join(volumeDir, path) |
|
|
|
|
|
|
|
|
|
|
|
filePath := filepath.Join(volumeDir, filepath.FromSlash(path)) |
|
|
|
file, err := os.Open(filePath) |
|
|
|
file, err := os.Open(filePath) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
if os.IsNotExist(err) { |
|
|
|
if os.IsNotExist(err) { |
|
|
|
return nil, errFileNotFound |
|
|
|
return nil, errFileNotFound |
|
|
|
|
|
|
|
} else if os.IsPermission(err) { |
|
|
|
|
|
|
|
return nil, errFileAccessDenied |
|
|
|
} |
|
|
|
} |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
@ -416,22 +430,12 @@ func (s fsStorage) ReadFile(volume string, path string, offset int64) (readClose |
|
|
|
|
|
|
|
|
|
|
|
// CreateFile - create a file at path.
|
|
|
|
// CreateFile - create a file at path.
|
|
|
|
func (s fsStorage) CreateFile(volume, path string) (writeCloser io.WriteCloser, err error) { |
|
|
|
func (s fsStorage) CreateFile(volume, path string) (writeCloser io.WriteCloser, err error) { |
|
|
|
if volume == "" || path == "" { |
|
|
|
volumeDir, err := s.checkVolumeArg(volume) |
|
|
|
return nil, errInvalidArgument |
|
|
|
if err != nil { |
|
|
|
} |
|
|
|
return nil, err |
|
|
|
if e := checkDiskFree(s.diskPath, s.minFreeDisk); e != nil { |
|
|
|
|
|
|
|
return nil, e |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
volumeDir := getVolumeDir(s.diskPath, volume) |
|
|
|
if err := checkDiskFree(s.diskPath, s.minFreeDisk); err != nil { |
|
|
|
// Verify if volume directory exists
|
|
|
|
return nil, err |
|
|
|
if exists, err := isDirExist(volumeDir); !exists { |
|
|
|
|
|
|
|
if err == nil { |
|
|
|
|
|
|
|
return nil, errVolumeNotFound |
|
|
|
|
|
|
|
} else if os.IsNotExist(err) { |
|
|
|
|
|
|
|
return nil, errVolumeNotFound |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
filePath := filepath.Join(volumeDir, path) |
|
|
|
filePath := filepath.Join(volumeDir, path) |
|
|
|
// Verify if the file already exists and is not of regular type.
|
|
|
|
// Verify if the file already exists and is not of regular type.
|
|
|
@ -445,33 +449,26 @@ func (s fsStorage) CreateFile(volume, path string) (writeCloser io.WriteCloser, |
|
|
|
|
|
|
|
|
|
|
|
// StatFile - get file info.
|
|
|
|
// StatFile - get file info.
|
|
|
|
func (s fsStorage) StatFile(volume, path string) (file FileInfo, err error) { |
|
|
|
func (s fsStorage) StatFile(volume, path string) (file FileInfo, err error) { |
|
|
|
if volume == "" || path == "" { |
|
|
|
volumeDir, err := s.checkVolumeArg(volume) |
|
|
|
return FileInfo{}, errInvalidArgument |
|
|
|
if err != nil { |
|
|
|
} |
|
|
|
return FileInfo{}, err |
|
|
|
volumeDir := getVolumeDir(s.diskPath, volume) |
|
|
|
|
|
|
|
// Verify if volume directory exists
|
|
|
|
|
|
|
|
var exists bool |
|
|
|
|
|
|
|
if exists, err = isDirExist(volumeDir); !exists { |
|
|
|
|
|
|
|
if err == nil { |
|
|
|
|
|
|
|
return FileInfo{}, errVolumeNotFound |
|
|
|
|
|
|
|
} else if os.IsNotExist(err) { |
|
|
|
|
|
|
|
return FileInfo{}, errVolumeNotFound |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return FileInfo{}, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
filePath := filepath.Join(volumeDir, path) |
|
|
|
filePath := filepath.Join(volumeDir, filepath.FromSlash(path)) |
|
|
|
st, err := os.Stat(filePath) |
|
|
|
st, err := os.Stat(filePath) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
|
|
|
|
// File is really not found.
|
|
|
|
if os.IsNotExist(err) { |
|
|
|
if os.IsNotExist(err) { |
|
|
|
return FileInfo{}, errFileNotFound |
|
|
|
return FileInfo{}, errFileNotFound |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// File path cannot be verified since one of the parents is a file.
|
|
|
|
if strings.Contains(err.Error(), "not a directory") { |
|
|
|
if strings.Contains(err.Error(), "not a directory") { |
|
|
|
return FileInfo{}, errIsNotRegular |
|
|
|
return FileInfo{}, errIsNotRegular |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Return all errors here.
|
|
|
|
return FileInfo{}, err |
|
|
|
return FileInfo{}, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// If its a directory its not a regular file.
|
|
|
|
if st.Mode().IsDir() { |
|
|
|
if st.Mode().IsDir() { |
|
|
|
return FileInfo{}, errIsNotRegular |
|
|
|
return FileInfo{}, errIsNotRegular |
|
|
|
} |
|
|
|
} |
|
|
@ -486,49 +483,55 @@ func (s fsStorage) StatFile(volume, path string) (file FileInfo, err error) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// deleteFile - delete file path if its empty.
|
|
|
|
// deleteFile - delete file path if its empty.
|
|
|
|
func deleteFile(basePath, deletePath, volume, path string) error { |
|
|
|
func deleteFile(basePath, deletePath string) error { |
|
|
|
if basePath == deletePath { |
|
|
|
if basePath == deletePath { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
// Verify if the path exists.
|
|
|
|
// Verify if the path exists.
|
|
|
|
pathSt, e := os.Stat(deletePath) |
|
|
|
pathSt, err := os.Stat(deletePath) |
|
|
|
if e != nil { |
|
|
|
if err != nil { |
|
|
|
return e |
|
|
|
if os.IsNotExist(err) { |
|
|
|
|
|
|
|
return errFileNotFound |
|
|
|
|
|
|
|
} else if os.IsPermission(err) { |
|
|
|
|
|
|
|
return errFileAccessDenied |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
if pathSt.IsDir() { |
|
|
|
if pathSt.IsDir() { |
|
|
|
// Verify if directory is empty.
|
|
|
|
// Verify if directory is empty.
|
|
|
|
empty, e := isDirEmpty(deletePath) |
|
|
|
empty, err := isDirEmpty(deletePath) |
|
|
|
if e != nil { |
|
|
|
if err != nil { |
|
|
|
return e |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
if !empty { |
|
|
|
if !empty { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Attempt to remove path.
|
|
|
|
// Attempt to remove path.
|
|
|
|
if e := os.Remove(deletePath); e != nil { |
|
|
|
if err := os.Remove(deletePath); err != nil { |
|
|
|
return e |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
// Recursively go down the next path and delete again.
|
|
|
|
// Recursively go down the next path and delete again.
|
|
|
|
if e := deleteFile(basePath, filepath.Dir(deletePath), volume, path); e != nil { |
|
|
|
if err := deleteFile(basePath, filepath.Dir(deletePath)); err != nil { |
|
|
|
return e |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// DeleteFile - delete a file at path.
|
|
|
|
// DeleteFile - delete a file at path.
|
|
|
|
func (s fsStorage) DeleteFile(volume, path string) error { |
|
|
|
func (s fsStorage) DeleteFile(volume, path string) error { |
|
|
|
if volume == "" || path == "" { |
|
|
|
volumeDir, err := s.checkVolumeArg(volume) |
|
|
|
return errInvalidArgument |
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
volumeDir := getVolumeDir(s.diskPath, volume) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Following code is needed so that we retain "/" suffix if any in
|
|
|
|
// Following code is needed so that we retain "/" suffix if any in
|
|
|
|
// path argument. Do not use filepath.Join() since it would strip
|
|
|
|
// path argument.
|
|
|
|
// off any suffixes.
|
|
|
|
filePath := filepath.Join(volumeDir, filepath.FromSlash(path)) |
|
|
|
filePath := s.diskPath + string(os.PathSeparator) + volume + string(os.PathSeparator) + path |
|
|
|
if strings.HasSuffix(filepath.FromSlash(path), string(os.PathSeparator)) { |
|
|
|
|
|
|
|
filePath = filePath + string(os.PathSeparator) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Delete file and delete parent directory as well if its empty.
|
|
|
|
// Delete file and delete parent directory as well if its empty.
|
|
|
|
return deleteFile(volumeDir, filePath, volume, path) |
|
|
|
return deleteFile(volumeDir, filePath) |
|
|
|
} |
|
|
|
} |
|
|
|