refactor: copy downloaded file according to torrent info

This commit is contained in:
Simon Ding
2025-01-31 19:34:18 +08:00
parent 1386626712
commit c01924ac3f
8 changed files with 92 additions and 35 deletions

View File

@@ -34,7 +34,7 @@ func NewWebdavStorage(url, user, password, path string, changeMediaHash bool, vi
}, nil
}
func (w *WebdavStorage) Copy(local, remoteDir string) error {
func (w *WebdavStorage) Copy(local, remoteDir string, walkFn WalkFn) error {
b, err := NewBase(local, w.videoFormats, w.subtitleFormats)
if err != nil {
return err
@@ -57,14 +57,7 @@ func (w *WebdavStorage) Copy(local, remoteDir string) error {
return b.Upload(filepath.Join(w.dir, remoteDir), false, true, w.changeMediaHash, uploadFunc, func(s string) error {
return nil
})
}
func (w *WebdavStorage) Move(local, remoteDir string) error {
if err := w.Copy(local, remoteDir); err != nil {
return err
}
return os.RemoveAll(local)
}, walkFn)
}
func (w *WebdavStorage) ReadDir(dir string) ([]fs.FileInfo, error) {