diff --git a/src/tribler-core/tribler_core/modules/watch_folder/watch_folder.py b/src/tribler-core/tribler_core/modules/watch_folder/watch_folder.py index 64cec32c465..bc0f18d5114 100644 --- a/src/tribler-core/tribler_core/modules/watch_folder/watch_folder.py +++ b/src/tribler-core/tribler_core/modules/watch_folder/watch_folder.py @@ -3,9 +3,7 @@ from pathlib import Path from ipv8.taskmanager import TaskManager - from tribler_common.simpledefs import NTFY - from tribler_core.modules.libtorrent.download_manager import DownloadManager from tribler_core.modules.libtorrent.torrentdef import TorrentDef from tribler_core.notifier import Notifier @@ -35,8 +33,12 @@ def cleanup_torrent_file(self, root, name): if not fullpath.exists(): self._logger.warning("File with path %s does not exist (anymore)", root / name) return + path = Path(str(fullpath) + ".corrupt") + try: + fullpath.rename(path) + except PermissionError as e: + self._logger.warning(f'Cant rename the file to {path}. Exception: {e}') - fullpath.rename(Path(str(fullpath)+".corrupt")) self._logger.warning("Watch folder - corrupt torrent file %s", name) self.notifier.notify(NTFY.WATCH_FOLDER_CORRUPT_FILE, name)