trim21 / transmission-rpc

https://transmission-rpc.readthedocs.io/en/stable/
MIT License
139 stars 34 forks source link

Can't delete file from disc #426

Closed garnajee closed 3 months ago

garnajee commented 3 months ago

Sorry to reopen this, but it seems that I have the same issue with the lib (latest version transmission-rpc==7.0.5).

By trying to delete a torrent (the file itself and the data) using the remove_torrent() function, only the file (<hash>.torrent in the transmission folder) is removed. It doesn't matter whether delete_data is set to True or False, the torrent file is always removed. But never the contents of the torrent.

Here is the json data request using the web-ui (with the webui it works fine) :

json_data = '{"arguments":{"delete-local-data":true,"ids":[151]},"method":"torrent-remove"}'

Here is my python script : client.remove_torrent(151,True)

I don't know what else I can provide, I don't have any other logs.

Thanks

Originally posted by @garnajee in https://github.com/trim21/transmission-rpc/issues/182#issuecomment-2118863024

trim21 commented 3 months ago

does your transmission process have permission to remove files?

trim21 commented 3 months ago

I still can't re-reproduce this. this library will send request data {'tag': 1, 'method': 'torrent-remove', 'arguments': {'delete-local-data': True, 'ids': [...]}} and it's same data with web-ui

garnajee commented 3 months ago

Thanks for the reply. Yes, transmission have the right permission to remove file (I'm using the linuxserver/transmission docker with the same puid/pgid as for the files. I even tried with root id).

How could I get the request data used by lib? I don't know what else to do/try.

trim21 commented 3 months ago

Thanks for the reply. Yes, transmission have the right permission to remove file (I'm using the linuxserver/transmission docker with the same puid/pgid as for the files. I even tried with root id).

How could I get the request data used by lib? I don't know what else to do/try.

set logging level to debug

https://github.com/trim21/transmission-rpc/blob/7a4a999b071119510025818f055c2868f0fcad21/transmission_rpc/constants.py#L8

garnajee commented 3 months ago

Thanks ! So, here is my python code for the tests:

#!/usr/bin/env python3
import logging
from transmission_rpc import Client

# Configure root logger to print DEBUG messages to console
logging.basicConfig(level=logging.DEBUG)

ip = "localhost"
port = 9091
username = "admin"
password = "admin"

client = Client(host=ip, port=port, username=username, password=password)

# Add a logger for transmission-rpc and set level to DEBUG
transmission_logger = logging.getLogger("transmission-rpc")
transmission_logger.setLevel(logging.DEBUG)

# Create a console handler for transmission-rpc logger
transmission_console_handler = logging.StreamHandler()
transmission_console_handler.setLevel(logging.DEBUG)

# Create a formatter and add it to the handler
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
transmission_console_handler.setFormatter(formatter)

# Add the console handler to the logger
transmission_logger.addHandler(transmission_console_handler)

# Remove torrent with ID 27 and log DEBUG messages
print("list:",client.get_torrents(arguments=["id", "name"]))
print("removing...")
client.remove_torrent(32,True)

And here is the full log : https://gist.github.com/garnajee/2ef96f1c7b6d64ec435fb6d00aae66a9

trim21 commented 3 months ago

you can see it generate same request data

https://gist.github.com/garnajee/2ef96f1c7b6d64ec435fb6d00aae66a9#file-logs-transmission-L201

garnajee commented 3 months ago

Yes, but the file still exists (not the <hash>.torrent, just the content)

trim21 commented 3 months ago

and I don't think it's possible that json only encode method and ids but not delete-local-data for request body...

trim21 commented 3 months ago

Can you 100% reproduce this? is there any extra log from transmission-daemon?

garnajee commented 3 months ago

Hello, sorry for the late reply I can reproduce this indefinitely. No other logs. 2nd test: https://gist.github.com/garnajee/160fd109213407b012e65b55f3022072 adding more information (tree before/after, docker-compose.yml, file's permissions)

garnajee commented 3 months ago

Ok, apologies, seems to work well finally. My fault...

services:
  transmission:
    ...
    volumes:
      - ./tr-config/:/config
-     - ./data:/data
    volumes:
      - ./tr-config/:/config
+     - ./data:/downloads
....
trim21 commented 3 months ago

happy to know it's not a but 😄

garnajee commented 3 months ago

I'm sorry again, I'm a bit ashamed ahah

trim21 commented 3 months ago

no need for apologies