Unable to edit torrents.state

General support for problems installing or using Deluge
Post Reply
sojkatz
New User
New User
Posts: 1
Joined: Sat Apr 04, 2020 8:35 am

Unable to edit torrents.state

Post by sojkatz »

Hi,
first thank you for your great work at Deluge!

My problem is, that I want to change my 'downloaded path' of my seeding torrents, because I had to change my drives [..].
I also tried to edit torrents.state and/or torrents.fastresume using Linux 'sed' command and manual by using nano.


But as soon as I replace (daemon already stopped) the old files with the new ones, correct file permissions/owner, and started the daemon, all my torrents were gone, zero.

If I recover the old orginal ones, everything is shown up, just with the old path, as espected.
Than I tried using Notepad++, different bencode editors (including bencode-pretty), but they all have problems with 'unexpected character �' which can be found many times at my state file.

So, how to 'mass change' my download path locations in state file proper?


Thanks,
sojkatz

Further Info:
Deluge 2.0.3
Linux

Used sed command:

Code: Select all

sed -i 's#/path_old/#/path_new/#g' torrents.state 
I also tried to reproduce it with a new fresh deluge install and one test torrent, but get the same error.
shamael
Compulsive Poster
Compulsive Poster
Posts: 667
Joined: Sat Oct 08, 2016 9:28 am

Re: Unable to edit torrents.state

Post by shamael »

Hi,

Are you sure the daemon was stopped? lsof the torrent.state doesn't show any process accessing it? I use the sed method to change the tracker w/o issue so it sounds correct.

the old path is still reachable or the hdd is dead? If reachable I'll consider a move through the interface (selec all>move storage).
but I guess it's not. Maybe you can create a symlink (LN command) to recreate the old path as a file and redirect it to the new location. when done, move all to the new location directly

Is it something doable in the current situation?

EDIT: for the symlink AND the new location do not forget the ACL, often omitted on the symlink
ScubaCaribe
New User
New User
Posts: 6
Joined: Sun Nov 20, 2022 10:24 pm

Re: Unable to edit torrents.state

Post by ScubaCaribe »

I would love to know how to edit the torrents.state file as well. I'm migrating Deluge 2.1 from Windows to Docker and the directory structure and file paths must be changed in order to retain the torrents. After hours of searching online, I've come up with no workable solution. Similarly to OP, I've tried the sed script to search/replace and various bencode editors to no avail. Does anyone have any suggestions?
User avatar
ambipro
Moderator
Moderator
Posts: 444
Joined: Thu May 19, 2022 3:33 am
Contact:

Re: Unable to edit torrents.state

Post by ambipro »

I believe it's expecting a string of path that is the same length and fails when its not, there is something in the encoding if memory serves...but I'm not sure.

When I migrated from windows to UNRAID - I just loaded it up, and paused, moved, and let them all recheck. Took a few days, but I couldn't get anything else to work (as you mention) - replacing tracker URL's is easy with https://gist.github.com/cas--/5326335 - not sure if you want to try editing python code and attempting to replace path's with this, but that might be a last ditch attempt.

Alternatively, just grab your state folder's torrents and add them all with skip recheck to the right path, hopefully its all in one folder :P
ScubaCaribe
New User
New User
Posts: 6
Joined: Sun Nov 20, 2022 10:24 pm

Re: Unable to edit torrents.state

Post by ScubaCaribe »

I gave up and did it the hard way. Set Deluge to add torrents in a paused state, copied the /state/ directory over from Windows to the docker container, used the client and selected 'Move Download Folder' for all 1100 torrents, and force rechecked all of them. Took a few hours but it was the only way I could reliably ensure Deluge kept everything. Luckily, many torrents shared the same download directory (Movies) but many did not (TV shows) fml. They'll be re-checking until tomorrow but my part is done now. Thanks for the reply and assistance. In the future, it would be great it there was a tool or script that could do this. You used to be able to manually edit Deluge 1.X's torrent.state file with Notepad++ (I don't recall seeing any binary code in it), but with Deluge 2.X, it's no longer manually editable. If someone out there knows of a secret editor or plugin for Notepad++ to do this, I'd be forever grateful!
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Unable to edit torrents.state

Post by mhertz »

Ambipro right, not surprisingly, and just wanted post a thread with some info, last post in thread in particular viewtopic.php?t=55923

Edit: Also this: viewtopic.php?p=235543#p235543

I also made a python script once I remember, with some search/replace functionality, e.g to just change part of path(e.g start) and keep rest, while also replacing windows to Linux path seperaters in whole path too, for when having changed yourself manually before away from default on some torrents, but don't have it anymore unfortunetly, or if find later somewhere maybe in my test windows VM, then will edit in.
ScubaCaribe
New User
New User
Posts: 6
Joined: Sun Nov 20, 2022 10:24 pm

Re: Unable to edit torrents.state

Post by ScubaCaribe »

Actually I did come across your post about the deluge_path_change.exe file and tried to get more information about it but couldn't find any. When I ran it initially I was expecting it to ask for me to specify the new file path but it seemed to automatically run without any type of prompts. I tried running it command prompt with the typical /? and /help switches but it didn't seem like those were built in. It's possible that I was using it incorrectly but after it ran the first time, it actually moved some of my downloaded movies and TV shows to the /state/ folder so I quit Deluge before any more issues came up.

Do you have any documentation on how to use the tool? It seems like exactly what I'm hoping for but I'd like the ability to customize what it does. I searched Google and haven't seen any other posts mention the tool except for the one you linked with your post.

I also saw your post in the first thread you linked but it looked like the perl script was more concerned with changing the torrent tracker URL (IIRC) and not the actual file paths for the torrents themselves.

Appreciate you helping me on this :)
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Unable to edit torrents.state

Post by mhertz »

You're welcome mate :)

Sorry I was little too quick there, and that last link with exe tool, is just meant for windows setups, not windows to linux(docker), so not good fit. It's little slow running, but opens a GUI path-chooser widget and you select a folder and it rewrites save_path with that folder for all torrents, and opens little window stating successful which auto-closes 20 secs after if not pressing 'OK' yourself. I just checked worked on my test win10 VM. It's very crude, and I just made quickly at the time. You have to move files over yourself, and i'm not sure if it need rechecking, but at-least works instead of failing.

For windows to linux, the python scripts of first link best, as can take a linux path.

Sorry for confusion.

Edit: If use(exe), then need deluge closed and sometimes for some reason the job successful message is minimized and as said auto-closes, but can be seen from taskbar or processbar whatever called on windows, that a window open, for those 20 secs. Always keep backups, profile/files, mistakes happen(me I mean). For the python3/deluge2 script, just download/extract embedded python zip archive under official python downloads(unless having python3 already), for windows I mean, and run from there in a cmd-prompt, and on linux just run in a terminal, as have python3 there surely.

Edit2: Sorry came to think about the python script doesn't work on windows in current state, as official installer freezed, so not importable from outside with deluge closed, and is needed in the pickle process I forgot, so need be run on linux.

Edit3: viewtopic.php?t=56553
Post Reply