* Fixes #1469 : Remove file that matches with the directory path * Fixes #1469 : Remove file that matches with the directory path * Fixes #1469 : Fix lint errors * Fixes #1469 : Fix lint errors * Fixes #1469 : Fix lint errors * Fixes #1469 : Reduce conditional depth * Fixes #1469 : Remove an additional line Co-authored-by: anugu-chegg <anugu.s@chegg.com>
This commit is contained in:
parent
bd5a08baf1
commit
9ed158c1f6
|
|
@ -749,6 +749,15 @@ func Volumes() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func mkdirAllWithPermissions(path string, mode os.FileMode, uid, gid int64) error {
|
func mkdirAllWithPermissions(path string, mode os.FileMode, uid, gid int64) error {
|
||||||
|
// Check if a file already exists on the path, if yes then delete it
|
||||||
|
info, err := os.Stat(path)
|
||||||
|
if !os.IsNotExist(err) && !info.IsDir() {
|
||||||
|
logrus.Tracef("removing file because it needs to be a directory %s", path)
|
||||||
|
if err := os.Remove(path); err != nil {
|
||||||
|
return errors.Wrapf(err, "error removing %s to make way for new directory.", path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := os.MkdirAll(path, mode); err != nil {
|
if err := os.MkdirAll(path, mode); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue