Page 1 of 1

unable to add torrent due to improper filename encoding

Posted: Sun Jul 17, 2016 9:14 pm
by nbcon
I've done a bit of searching on how to solve this, and i'm still at square one. Hopefully someone can help me out here!

I am running deluged remotely on a raspberry pi with a newish version of jessie. I followed steps on these pages to install:
http://www.howtogeek.com/142044/how-to- ... rrent-box/
http://dev.deluge-torrent.org/wiki/User ... buntuInitd


When i attempt to auto-add a torrent with a non-ascii filename (for example: Aníbal Velásquez y Su Conjunto - Mambo Loco.torrent), deluge fails to add anything and deluged.log returns:
Unable to auto add torrent due to improper filename encoding: 'ascii' codec can't decode byte 0xf1 in position 45: ordinal not in range(128)
When I attempt to add the torrent remotely (via the deluge client on my mac), nothing is added and i can't seem to find a trace of the action in my logfile. If i remove the offending characters from the name of the file (for example: test.torrent), neither the auto-add nor the manual add work, and nothing is logged (likely because some of the torrent's files have non-ascii filenames). Here are the pages i have looked over while debugging:

http://forum.deluge-torrent.org/viewtopic.php?t=42821
http://dev.deluge-torrent.org/ticket/1981
http://dev.deluge-torrent.org/ticket/1983
http://dev.deluge-torrent.org/ticket/2301

Most of those pages are several years old, and in most cases the issue was resolved, so i am hopeful! The main take-away from those pages is that the OS is not running in UTF-8. I have confirmed that mine is, however:

Code: Select all

$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
And so I am not sure what the problem is. Can anyone help me out? This is driving me nuts...

Re: unable to add torrent due to improper filename encoding

Posted: Sun Jul 17, 2016 9:29 pm
by Cas
The top of that linked initd guide reads:
This page is for obsolete/unsupported Ubuntu distributions, see systemd or Upstart depending on your distribution.
See the main Service wiki page: http://dev.deluge-torrent.org/wiki/UserGuide/Service

The locale depends on the user that runs deluge and those linked tickets specifically mention that and do have suggestions to try. If you read the ticket you would see their age is irrelevant were closed because it's not a bug in Deluge but a locale setup issue.

Re: unable to add torrent due to improper filename encoding

Posted: Sun Jul 17, 2016 11:04 pm
by nbcon
Thanks for the quick reply Cas.

I have updated my config as per: http://dev.deluge-torrent.org/wiki/User ... ce/systemd

I have tried using "deluge" user as the service user, as well as my own username, and the issue persists. Following this user's post, i have tried (to no avail) setting the locale to en_US.UTF-8 in .bashrc as well as in the systemd script (adding LC_ALL=en_US.UTF-8 to /etc/systemd/system/deluged.service):
http://forum.deluge-torrent.org/viewtop ... 10#p213803

Am i missing something critical here? I was unable to figure out what i'm supposed to do with the git diff in your final reply for ticket #1983. Is that the key?

Re: unable to add torrent due to improper filename encoding

Posted: Tue Jul 19, 2016 9:21 am
by Cas
Serverfault: How to set environment variable in systemd service? wrote: For instance, in a file /etc/systemd/system/myservice.service.d/myenv.conf:

[Service]
Environment="SECRET=pGNqduRFkB4K9C2vijOmUDa2kPtUhArN"
Environment="ANOTHER_SECRET=JP8YLOc2bsNlrGuD6LVTq7L36obpjzxd"
So try Environment="LC_ALL=en_US.UTF-8" in systemd service file.

The code change is to verify that the problem exists so you can test it if you wish if it's still not fixed by the above.

Re: unable to add torrent due to improper filename encoding

Posted: Tue Jul 19, 2016 2:10 pm
by nbcon
Thanks for the suggestion!

The problem persists after adding Environment="LC_ALL=en_US.UTF-8" to /etc/systemd/system/deluged.service and reboot. Is it possible that something funky is still around after switching from the init.d config (following the systemd userguide)? For example, my logs are still being sent to ~/.config/deluge/deluged.log, even though my ExecStart line is as follows:

Code: Select all

ExecStart=/usr/bin/deluged -d -l /var/log/deluge/daemon.log -L warning
To be clear, i don't care so much about the location of the log, only about whether there is some "carry over" from the previous config.

Re: unable to add torrent due to improper filename encoding

Posted: Tue Jul 19, 2016 2:47 pm
by Cas
Did you stop and delete the other service... http://dev.deluge-torrent.org/wiki/User ... artscripts

Re: unable to add torrent due to improper filename encoding

Posted: Thu Jul 21, 2016 2:46 pm
by nbcon
I initally deleted the service following exactly:
http://dev.deluge-torrent.org/wiki/User ... artscripts

But it looks like there was still an rc.local entry. I commented out the entry in rc.local, and also ran:

Code: Select all

sudo update-rc.d deluge-web remove
sudo update-rc.d deluged remove
Which seems to have fixed the log file issue (now it is sent to /var/log/deluge/daemon.log, and i have confirmed that this is operational). However, the file name encoding is still a problem. Now, when I auto-add or manually add a torrent with non-standard characters, nothing is added and nothing is logged. I have confirmed that everything works when the files (both the torrent file and the files to be downloaded) are ascii compatible.

Can you think of any reason why this would still be the case, even when the environment is set correctly for my user as well as in systemd? For reference here is my systemd file:

Code: Select all

[Unit]
Description=Deluge Bittorrent Client Daemon
After=network-online.target

[Service]
Type=simple
User=pi
Group=pi
UMask=022
Environment="LC_ALL=en_US.UTF-8"

ExecStart=/usr/bin/deluged -d -l /var/log/deluge/daemon.log -L warning

Restart=on-failure

# Configures the time to wait before service is stopped forcefully.
TimeoutStopSec=300

# Unit starts after the following mounts are available.
RequiresMountsFor=media-MEDIA.mount
 
# Unit is stopped when any of these mounts disappear.
BindsTo=media-MEDIA.mount

[Install]
WantedBy=multi-user.target