bug fix: deletes cross-seed torrents too

This commit is contained in:
Jon 2021-09-25 11:36:22 -04:00
parent 60707a9b37
commit c106ee7904
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671

View file

@ -486,9 +486,11 @@ def tag_nohardlinks():
remote_path = root_path
if 'Movie' in nohardlinks:
t_count = 0
t_del = 0
t_count = 0 #counter for the number of torrents that has no hard links
t_del = 0 #counter for the number of torrents that has no hard links and meets the criteria for ratio limit/seed limit for deletion
t_del_cs = 0 #counter for the number of torrents that has no hard links and meets the criteria for ratio limit/seed limit for deletion including cross-seeds
n_info = ''
tdel_dict = {} #dictionary to track the torrent names and content path that meet the deletion criteria
if 'category' not in nohardlinks['Movie']:
logger.error('category not defined in config inside the nohardlinks/Movies variable. Please make sure to fill out category in nohardlinks Movie section.')
torrent_list = client.torrents.info(category=nohardlinks['Movie']['category'],filter='completed')
@ -526,11 +528,25 @@ def tag_nohardlinks():
if ('cleanup' in nohardlinks['Movie'] and nohardlinks['Movie']['cleanup'] and torrent.state_enum.is_paused):
t_del += 1
n_info += (f'\n - Torrent Name: {torrent.name} has no hard links found and meets ratio/seeding requirements.')
tdel_dict[torrent.name] = torrent['content_path'].replace(root_path,remote_path)
if args.dry_run == 'dry_run':
n_info += (' \n Cleanup flag set to true. NOT Deleting torrent + contents.')
else:
n_info += (' \n Cleanup flag set to true. Deleting torrent + contents.')
#torrent.delete(hash=torrent.hash, delete_files=True)
#loop through torrent list again for cleanup purposes
for torrent in torrent_list:
if torrent.name in tdel_dict.keys() and 'noHL' in torrent.tags:
#Double check that the content path is the same before we delete anything
if torrent['content_path'].replace(root_path,remote_path) == tdel_dict[torrent.name]:
t_del_cs += 1
if (os.path.exists(torrent['content_path'].replace(root_path,remote_path))):
torrent.delete(hash=torrent.hash, delete_files=True)
else:
torrent.delete(hash=torrent.hash, delete_files=False)
#Checks to see if previous noHL tagged torrents now have hard links.
if (not (nohardlink(torrent['content_path'].replace(root_path,remote_path))) and ('noHL' in torrent.tags)):
@ -548,6 +564,7 @@ def tag_nohardlinks():
logger.dryrun(f'Did not tag/set ratio limit/seeding time for {t_count} .torrents(s)')
if t_del >= 1:
logger.dryrun(f'Did not delete {t_del} .torrents(s) or content files.')
logger.dryrun(f'Did not delete {t_del_cs} .torrents(s) (including cross-seed) or content files.')
else:
logger.dryrun('No torrents to tag with no hard links.')
else:
@ -557,6 +574,7 @@ def tag_nohardlinks():
logger.info(f'tag/set ratio limit/seeding time for {t_count} .torrents(s)')
if t_del >= 1:
logger.dryrun(f'Deleted {t_del} .torrents(s) AND content files.')
logger.dryrun(f'Deleted {t_del_cs} .torrents(s) (includes cross-seed torrents) AND content files.')
else:
logger.info('No torrents to tag with no hard links.')