-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug_download.py
More file actions
65 lines (53 loc) · 2.17 KB
/
debug_download.py
File metadata and controls
65 lines (53 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# debug_download.py
#!/usr/bin/env python3
import os
import time
from torrent import Torrent
from pieces_manager import PiecesManager
def debug_download_process(torrent_path):
print("🔍 DEBUGGING DOWNLOAD PROCESS")
print("=" * 50)
# Load torrent
torrent = Torrent().load_from_path(torrent_path)
if not torrent:
print("❌ Failed to load torrent")
return
print(f"📁 Torrent: {torrent.name}")
print(f"📊 Size: {torrent.total_length} bytes")
print(f"🧩 Pieces: {torrent.number_of_pieces}")
# Check if files already exist
print("\n📋 CHECKING EXISTING FILES:")
for file_info in torrent.file_names:
path = file_info["path"]
expected_size = file_info["length"]
if os.path.exists(path):
actual_size = os.path.getsize(path)
status = "✅ CORRECT" if actual_size == expected_size else "❌ WRONG SIZE"
print(f" {path}: {actual_size}/{expected_size} bytes - {status}")
else:
print(f" {path}: ❌ MISSING")
# Initialize pieces manager
print("\n🧩 INITIALIZING PIECES MANAGER:")
pieces_manager = PiecesManager(torrent)
# Check piece states
print("\n🔍 CHECKING PIECE STATES:")
completed_pieces = 0
for i, piece in enumerate(pieces_manager.pieces):
if piece.is_full:
completed_pieces += 1
print(f" Piece {i}: ✅ ALREADY COMPLETE")
else:
print(f" Piece {i}: ⏳ NEEDS DOWNLOAD - {piece.get_completion_percentage():.1f}%")
print(f"\n📊 SUMMARY: {completed_pieces}/{len(pieces_manager.pieces)} pieces already complete")
if completed_pieces == len(pieces_manager.pieces):
print("🚨 ALL PIECES ALREADY MARKED AS COMPLETE!")
print("💡 This is why download appears instant")
print("💡 Check if files were created by previous runs")
else:
print("✅ Some pieces need downloading - process should work normally")
if __name__ == "__main__":
import sys
if len(sys.argv) != 2:
print("Usage: python debug_download.py <torrent_file>")
sys.exit(1)
debug_download_process(sys.argv[1])