jslay88 / qbt_migrate

Migrate qBittorrent downloads
MIT License
162 stars 10 forks source link

Error right after starting #9

Closed birdie1 closed 3 years ago

birdie1 commented 3 years ago

When I try to use qbt_migrate it produces the following error:

BT_Backup Path (/home/USER/.local/share/data/qBittorrent/BT_backup): 
Target OS (Windows, Linux, Mac, Blank for same as existing): 
INFO:qbt_migrate.classes.QBTBatchMove:Creating Archive /home/USER/.local/share/data/qBittorrent/fastresume_backup20210509234754.zip ...
INFO:qbt_migrate.classes.QBTBatchMove:Done!
INFO:qbt_migrate.classes.QBTBatchMove:Searching for .fastresume files with path /home/USER/temp ...
Traceback (most recent call last):
  File "/home/USER/.local/lib/python3.9/site-packages/bencode/__init__.py", line 180, in bdecode
    r, l = decode_func[value[0:1]](value, 0)
KeyError: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/USER/.local/bin/qbt_migrate", line 8, in <module>
    sys.exit(main())
  File "/home/USER/.local/lib/python3.9/site-packages/qbt_migrate/cli.py", line 49, in main
    qbm.run(args.existing_path, args.new_path, args.target_os)
  File "/home/USER/.local/lib/python3.9/site-packages/qbt_migrate/classes.py", line 45, in run
    for fast_resume in self.discover_relevant_fast_resume(self.bt_backup_path, existing_path):
  File "/home/USER/.local/lib/python3.9/site-packages/qbt_migrate/classes.py", line 63, in discover_relevant_fast_resume
    fast_resume = FastResume(os.path.join(bt_backup_path, file))
  File "/home/USER/.local/lib/python3.9/site-packages/qbt_migrate/classes.py", line 95, in __init__
    self._data = bencode.bread(self.file_path)
  File "/home/USER/.local/lib/python3.9/site-packages/bencode/__init__.py", line 325, in bread
    return bdecode(fd.read())
  File "/home/USER/.local/lib/python3.9/site-packages/bencode/__init__.py", line 182, in bdecode
    raise BencodeDecodeError("not a valid bencoded string")
bencode.exceptions.BencodeDecodeError: not a valid bencoded string
jslay88 commented 3 years ago

Looks like it’s trying to read a corrupted fast resume file.

Can you post the problematic file?

On Sun, May 9, 2021 at 15:52 Jonas Vogel @.***> wrote:

When I try to use qbt_migrate it produces the following error:

BT_Backup Path (/home/USER/.local/share/data/qBittorrent/BT_backup): Target OS (Windows, Linux, Mac, Blank for same as existing): INFO:qbt_migrate.classes.QBTBatchMove:Creating Archive /home/USER/.local/share/data/qBittorrent/fastresume_backup20210509234754.zip ... INFO:qbt_migrate.classes.QBTBatchMove:Done! INFO:qbt_migrate.classes.QBTBatchMove:Searching for .fastresume files with path /home/USER/temp ... Traceback (most recent call last): File "/home/USER/.local/lib/python3.9/site-packages/bencode/init.py", line 180, in bdecode r, l = decode_func[value[0:1]](value, 0) KeyError: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/USER/.local/bin/qbt_migrate", line 8, in sys.exit(main()) File "/home/USER/.local/lib/python3.9/site-packages/qbt_migrate/cli.py", line 49, in main qbm.run(args.existing_path, args.new_path, args.target_os) File "/home/USER/.local/lib/python3.9/site-packages/qbt_migrate/classes.py", line 45, in run for fast_resume in self.discover_relevant_fast_resume(self.bt_backup_path, existing_path): File "/home/USER/.local/lib/python3.9/site-packages/qbt_migrate/classes.py", line 63, in discover_relevant_fast_resume fast_resume = FastResume(os.path.join(bt_backup_path, file)) File "/home/USER/.local/lib/python3.9/site-packages/qbt_migrate/classes.py", line 95, in init self._data = bencode.bread(self.file_path) File "/home/USER/.local/lib/python3.9/site-packages/bencode/init.py", line 325, in bread return bdecode(fd.read()) File "/home/USER/.local/lib/python3.9/site-packages/bencode/init.py", line 182, in bdecode raise BencodeDecodeError("not a valid bencoded string") bencode.exceptions.BencodeDecodeError: not a valid bencoded string

β€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jslay88/qbt_migrate/issues/9, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABO7UUOYS5VMSMNIVOYDJODTM372HANCNFSM44PWBAOQ .

birdie1 commented 3 years ago

While started posting the file, I noticed, that is was a zero byte file. Somehow I had some zero byte files. I removed those, now it is working fine. Thanks for the quick answer!

pressRtowin commented 3 years ago

I've found that qbittorrent frequently leaves leftover 0-byte fastresume files from removed torrents. This script works very well as long as none of those are present. Maybe some routine can be added to automatically skip 0-byte files or delete them to smooth out the process a bit more. I had to do some digging to figure out what was going on (as I have around 5000 torrents). Took me a moment to realize that all the problematic fastresume files were for torrents that no longer existed in my client and that I could just delete them.

jslay88 commented 3 years ago

You mean like v2.1.0 from 2 months ago?

https://github.com/jslay88/qbt_migrate/releases

pressRtowin commented 3 years ago

heh, didn't see that. I didn't actually know of the 0-byte file issue until I ran into issues running the script so I overlooked the "bad files" bit in the changes since I had no clue what that was referring to at the time πŸ€·πŸ»β€β™‚οΈ. I got all of my torrents migrated over successfully though, so thanks! Just gotta do some cleanup now . . . (On that note, you wouldn't consider extending the script to also check/change the save paths set for categories would you? I have quite a lot, and changing them all from non-existent directories is a huge pain, as the application hangs upon entering the "Edit" dialogue for each one, due to the non-existent directory. I hope this isn't yet another flag I missed πŸ˜…)