Skip to content

Commit

Permalink
Fix torrent validation error prints
Browse files Browse the repository at this point in the history
fixes #107
  • Loading branch information
Audionut committed Oct 26, 2024
1 parent 2541ccb commit 0782dc8
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ async def find_existing_torrent(self, meta):
async def is_valid_torrent(self, meta, torrent_path, torrenthash, torrent_client, print_err=False):
valid = False
wrong_file = False
err_print = ""

# Normalize the torrent hash based on the client
if torrent_client in ('qbit', 'deluge'):
Expand Down Expand Up @@ -174,28 +173,24 @@ async def is_valid_torrent(self, meta, torrent_path, torrenthash, torrent_client

# Piece size and count validations
if (reuse_torrent.pieces >= 7000 and reuse_torrent.piece_size < 8388608) or (reuse_torrent.pieces >= 4000 and reuse_torrent.piece_size < 4194304):
err_print = "[bold yellow]Too many pieces exist in current hash. REHASHING"
console.print("[bold yellow]Too many pieces exist in current hash. REHASHING")
valid = False
elif reuse_torrent.piece_size < 32768:
err_print = "[bold yellow]Piece size too small to reuse"
console.print("[bold yellow]Piece size too small to reuse")
valid = False
elif wrong_file:
err_print = "[bold red] Provided .torrent has files that were not expected"
console.print("[bold red] Provided .torrent has files that were not expected")
valid = False
else:
err_print = f'[bold green]REUSING .torrent with infohash: [bold yellow]{torrenthash}'
console.print(f"[bold green]REUSING .torrent with infohash: [bold yellow]{torrenthash}")
except Exception as e:
console.print(f'[bold red]Error checking reuse torrent: {e}')
valid = False

if meta['debug']:
console.log(f"Final validity after piece checks: valid={valid}")
else:
err_print = '[bold yellow]Unwanted Files/Folders Identified'

# Print the error message if needed
if print_err:
console.print(err_print)
console.print("[bold yellow]Unwanted Files/Folders Identified")

return valid, torrent_path

Expand Down

0 comments on commit 0782dc8

Please sign in to comment.