Sorry no solution, atleast yet, but anyway just posting because I tested this(as I thought would work) and I also had issues, and so reading up upon it, then it seems binary file-edits needs be same length, and probably the tracker-keys are same length already, but paths often not. It's stated to add null bytes if path shorter, and I tried that, i.e. add '\x00' four times after the changed path as 4 chars shorter, and in vim it's listed correctly with the four '^@' control chars prepended, which is '\x00' in "other writing". I tried using binary mode also, in sed, to no avail and tried bbe, the binary sed alternative, and whatnot, but no luck. I also ran the sed on the fastresume and also deleted it in other try with no change. Only thing working for me where shamael's instructions and a path of exact same char-length, which when also done to fastresume started and was seeding instantously without no recheck needs. I also tried hex-encoder without succes, but mind you, i'm complete noob at all this, so more a testiment of my disabilities than anything else
I tried running pickling afterwards also, despite not even knowing much what's about honestly, and also trying Cas's script with python2 and still no-go. Strange thing is that when I use sed with the null chars appended, then details tab in deluge shows the path change as correct, but still fails and output from deluge is 'unable to locate download folder' and after I recheck all then '* is a directory', where '*' is some char I don't know, looking like quote char, but again is listed perfectly under details.
Anyway, just wanted to add that and sorry no actual solution to this.
Edit: Sorry, I know this isn't an issue for OP anymore, but just for feature reference I mean, as do come up on occasion.
Edit2: Debug log shows, just for completeness, showing the null bytes, atleast in my way, isn't correct(and original location btw was /home/martin/Downloads, and here using deluge2 on linux):
Code: Select all
20:59:18.356 [DEBUG ][deluge.core.torrentmanager :473 ] options: {'add_paused': False, 'auto_managed': True, 'download_location': '/home/martin/video\x00\x00\x00\x00', 'max_connections': -1, 'max_download_speed': -1.0, 'max_upload_slots': -1, 'max_upload_speed': -1.0, 'move_completed': False, 'move_completed_path': '/home/martin/video\x00\x00\x00\x00', 'pre_allocate_storage': False, 'prioritize_first_last_pieces': False, 'remove_at_ratio': False, 'sequential_download': False, 'shared': False, 'stop_at_ratio': False, 'stop_ratio': 2.0, 'super_seeding': False, 'file_priorities': [4], 'mapped_files': {}, 'name': '', 'owner': 'localclient', 'seed_mode': False}
[...]
20:59:18.975 [DEBUG ][deluge.core.alertmanager :130 ] torrent_error_alert: archlinux-2021.08.01-x86_64.iso ERROR: (21 Is a directory) /home/martin/video
Edit3: Probably best to unpickle, replace and repickle, to support varying path lengths correctly, so tried change Cas script, which find 'url' indexes in 'trackers' param and replaces, so instead changed to iterate over 'save_path' and made python3/deluge2 script i.e. cPicke to pickle, raw_input() to input() etc, but still have issues as not good at this. I added some print statements, to debug and it ierates and prints save_path correctly for all torrents, but one char on each new line. I'll mess with it little more if have time tomorow, but not much confident in this regarding myself.
Edit4: For feature reference, then this is adapted version of Cas's python2 tracker-key-change script now for python3 and deluge2, sorry to lazy to find and rebuild old versions of boost and libtorrent and install, test, uninstall, for testing on deluge1/python2 - i dropped all the tracker/url/index stuff and adapted to iterate and replace 'save_path' instead, so it now asks for old/new paths and afterwards unpickle, replaces save_path and repickle, with old state backed up - also original script used own user deluge-profile-dir, so I changed it to ask you for path to your torrents.state file(all inputs can be copy/pasted in), so works for deluge user also, but then run script under sudo i.e. 'sudo python3 <scriptname>':
Code: Select all
import os
import sys
import platform
import shutil
import pickle
orig_tracker_url = input('Original path: ')
new_tracker_url = input('New path: ')
if platform.system() in ('Windows', 'Microsoft'):
state_file_path = os.path.join(os.environ.get('APPDATA'), 'deluge', 'state', 'torrents.state')
deluge_dir = os.path.join(os.environ['ProgramFiles'], 'Deluge')
if os.path.isdir(deluge_dir):
sys.path.append(deluge_dir)
sys.path.append(os.path.join(deluge_dir, 'Lib', 'site-packages'))
else:
state_file_path = input('Path to your torrents.state file: ')
state_file = open(state_file_path, 'rb')
state = pickle.load(state_file)
state_file.close()
state_modified = False
for torrent in state.torrents:
if torrent.save_path == orig_tracker_url:
if new_tracker_url:
torrent.save_path = new_tracker_url
state_modified = True
if state_modified:
shutil.copyfile(state_file_path, state_file_path + '.old')
state_file = open(state_file_path, 'wb')
pickle.dump(state, state_file)
state_file.close()
Edit5: Last edit, sorry
I adapted my ammended Cas script to deluge1/python2 and tested it on linux. Also, as this is the windows sub-forum, then I exceptionally tested this on windows also, by ssh/vnc'ed into a family-member's windows PC and borrowed it for some quick testing, and note you need use the python2 x32 installer for some reason(even despite changing the os.environ['ProgramFiles'] to the x86 version, and verified it, but still complained about not being able to load a dll when using x64 python, so use x32 instead). Anyway, I used latest v2.7.18, but if using a py2.6 deluge install instead of py2.7, then use a python 2.6 x32 installer instead. You don't need add path to torrents.state here, and no admin rights needed, and when entering old/new paths then enter normal windows paths(single backslashes) without quotes and spaces allowed.
I also edited previous script for deluge2/python3 to work also on the unofficial deluge2 installers for windows, but note you need the x64 python installer or x64 python-embedded zip package, in same version(just major and minor version important and not micro) as the python included in the unofficial installer, which you can check in deluge install folder which have a file named e.g. python38.dll for python 3.8.x and python39.dll for 3.9.x etc. As said, I made the script work with those, but however, for unofficial installers specifically, then easiest is to just open a cmd-prompt into installed deluge folder and run 'python <PATH-TO-SCRIPT>', so don't even need install any python additionally to run script, but only works for unofficial deluge2 installers. I tested this with unofficial installers own included python, python installer and python-embedded zip package, for petersasi's and my version.
Anyway, here follows the deluge1/python2 script as mentioned in beginning of this 'Edit5':
Code: Select all
import os
import sys
import platform
import shutil
import cPickle
orig_tracker_url = raw_input('Original path: ')
new_tracker_url = raw_input('New path: ')
if platform.system() in ('Windows', 'Microsoft'):
state_file_path = os.path.join(os.environ.get('APPDATA'), 'deluge', 'state', 'torrents.state')
deluge_dir = os.path.join(os.environ['ProgramFiles'], 'Deluge')
if os.path.isdir(deluge_dir):
sys.path.append(deluge_dir)
for item in os.listdir(deluge_dir):
if item.endswith(('.egg', '.zip')):
sys.path.append(os.path.join(deluge_dir, item))
else:
state_file_path = raw_input('Path to your torrents.state file: ')
state_file = open(state_file_path, 'rb')
state = cPickle.load(state_file)
state_file.close()
state_modified = False
for torrent in state.torrents:
if torrent.save_path == orig_tracker_url:
if new_tracker_url:
torrent.save_path = new_tracker_url
state_modified = True
if state_modified:
shutil.copyfile(state_file_path, state_file_path + '.old')
state_file = open(state_file_path, 'wb')
cPickle.dump(state, state_file)
state_file.close()