fix regression in webdav file removal logic (#162)
This commit is contained in:
@@ -101,15 +101,20 @@ func (h *Handler) RemoveAll(ctx context.Context, name string) error {
|
|||||||
if len(parts) >= 2 {
|
if len(parts) >= 2 {
|
||||||
if utils.Contains(h.getParentItems(), parts[0]) {
|
if utils.Contains(h.getParentItems(), parts[0]) {
|
||||||
torrentName := parts[1]
|
torrentName := parts[1]
|
||||||
|
cached := h.cache.GetTorrentByName(torrentName)
|
||||||
|
if cached != nil && len(parts) >= 3 {
|
||||||
filename := filepath.Clean(path.Join(parts[2:]...))
|
filename := filepath.Clean(path.Join(parts[2:]...))
|
||||||
if err := h.cache.RemoveFile(torrentName, filename); err != nil {
|
if file, ok := cached.GetFile(filename); ok {
|
||||||
h.logger.Error().Err(err).Msgf("Failed to remove file %s from torrent %s", filename, torrentName)
|
if err := h.cache.RemoveFile(cached.Id, file.Name); err != nil {
|
||||||
|
h.logger.Error().Err(err).Msgf("Failed to remove file %s from torrent %s", file.Name, torrentName)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// If the file was successfully removed, we can return nil
|
// If the file was successfully removed, we can return nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user