fix(renamer): only log rename operations that actually succeed

Previously, the rename log message was printed before checking if the
qBittorrent API call succeeded. This caused log spam when rename
operations failed (e.g., due to 409 conflicts or network errors) since
the same file would be attempted again on the next cycle.

Now the log message is only printed after confirming the rename
succeeded, reducing noise in the logs.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
Estrella Pan
2026-01-27 07:04:49 +01:00
parent 24f1f72941
commit 7e9f3a707a

View File

@@ -121,10 +121,14 @@ class DownloadClient(TorrentPath):
return await self.client.torrents_files(torrent_hash=torrent_hash)
async def rename_torrent_file(self, _hash, old_path, new_path) -> bool:
logger.info(f"{old_path} >> {new_path}")
return await self.client.torrents_rename_file(
result = await self.client.torrents_rename_file(
torrent_hash=_hash, old_path=old_path, new_path=new_path
)
if result:
logger.info(f"{old_path} >> {new_path}")
else:
logger.debug(f"[Downloader] Rename failed: {old_path} >> {new_path}")
return result
async def delete_torrent(self, hashes, delete_files: bool = True):
await self.client.torrents_delete(hashes, delete_files=delete_files)