Skip to content

Commit

Permalink
fix: clean dir
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ding committed Jul 12, 2024
1 parent 643351d commit 1b3faa7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/storage/webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ func NewWebdavStorage(url, user, password string) (*WebdavStorage, error) {

func (w *WebdavStorage) Move(local, remote string) error {
baseLocal := filepath.Base(local)
remoteBase := filepath.Join(remote, baseLocal)

log.Infof("remove all content in %s", remoteBase)
w.fs.RemoveAll(remoteBase)
err := filepath.Walk(local, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return errors.Wrapf(err, "read file %v", path)
Expand All @@ -36,7 +39,7 @@ func (w *WebdavStorage) Move(local, remote string) error {
if err != nil {
return errors.Wrap(err, "path relation")
}
remoteName := filepath.Join(remote, baseLocal, rel)
remoteName := filepath.Join(remoteBase, rel)

if info.IsDir() {

Expand Down

0 comments on commit 1b3faa7

Please sign in to comment.