fix regression in webdav file removal logic (#162)

This commit is contained in:
rotecode
2025-10-21 11:50:26 +02:00
committed by GitHub
parent 2a4f09c06d
commit f21f5cad94

View File

@@ -101,13 +101,18 @@ 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]
filename := filepath.Clean(path.Join(parts[2:]...)) cached := h.cache.GetTorrentByName(torrentName)
if err := h.cache.RemoveFile(torrentName, filename); err != nil { if cached != nil && len(parts) >= 3 {
h.logger.Error().Err(err).Msgf("Failed to remove file %s from torrent %s", filename, torrentName) filename := filepath.Clean(path.Join(parts[2:]...))
return err if file, ok := cached.GetFile(filename); ok {
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
}
// If the file was successfully removed, we can return nil
return nil
}
} }
// If the file was successfully removed, we can return nil
return nil
} }
} }