feat: skip creating an existing folder

pull/761/head
Xhofe 2022-03-11 18:12:13 +08:00
parent 8a62d55efe
commit 4b540a2297
2 changed files with 5 additions and 5 deletions

View File

@ -158,10 +158,6 @@ func (driver MediaTrack) Preview(path string, account *model.Account) (interface
}
func (driver MediaTrack) MakeDir(path string, account *model.Account) error {
_, err := driver.File(path, account)
if err != base.ErrPathNotFound {
return nil
}
parentFile, err := driver.File(utils.Dir(path), account)
if err != nil {
return err

View File

@ -29,7 +29,11 @@ func File(driver base.Driver, account *model.Account, path string) (*model.File,
func MakeDir(driver base.Driver, account *model.Account, path string, clearCache bool) error {
log.Debugf("mkdir: %s", path)
err := driver.MakeDir(path, account)
_, err := Files(driver, account, path)
if err != base.ErrPathNotFound {
return nil
}
err = driver.MakeDir(path, account)
if err == nil && clearCache {
_ = base.DeleteCache(utils.Dir(path), account)
}