rndusr / stig

TUI and CLI for the BitTorrent client Transmission
GNU General Public License v3.0
554 stars 24 forks source link

Stig not deleting torrent data when using rm -d #221

Closed Czechball closed 2 years ago

Czechball commented 2 years ago

Issue in the title. My system: Debian 4.19.208-1 Python 3.7.3 pip 22.0.4 stig version 0.12.3a0 installed from pip When trying to delete multiple torrents with the -d parameter (which should also delete the torrent's files), it only removes the torrents from Transmission but not the files. There were no errors in the command output. Here's the command I used: stig rm -d 'seeds>25&size>800MB&added<2022-01-01&tracker!~trackername' This found 47 torrents and prompted me if I want to delete all of them, to which I answered with "y". Following this, it showed me the output of deleting all the torrents: remove: Deleting ... (including files). The torrents were succesfully deleted from Transmission, but their files stayed untouched. One fact that might be related is that my mounted storage where the torrents are might've been completely full while running this command.

rndusr commented 2 years ago

One fact that might be related is that my mounted storage where the torrents are might've been completely full while running this command.

Pretty sure that's the issue. I think I've also seen this. I don't think stig can do anything about this and the issue is in upstream Transmission.

If you really care about this, please confirm that the issue is in Transmission by reproducing it with the transmission-remote CLI tool and report this upstream.

Czechball commented 2 years ago

I'll give that a try, thanks. The only problem here is that now I have to manually find all the abandoned torrent directories and manually delete them... Maybe I could solve this by moving all the active torrent files to a different temporary directory and them deleting everything what's left in the old one

Czechball commented 2 years ago

Closing this as it doesn't seem like a Stig issue

rndusr commented 1 year ago

I have a script for that. It gets a list of all files from stig and a list of all files from the common parent directory of all download locations and shows you the difference.

#!/bin/bash

set -o nounset

path="$1"

torrent_files="/tmp/$(basename "$0").torrent_files"
existing_files="/tmp/$(basename "$0").existing_files"
existing_dirs="/tmp/$(basename "$0").existing_dirs"

function cleanup() {
    rm -f "$torrent_files"
    rm -f "$existing_files"
    rm -f "$existing_dirs"
}
trap cleanup EXIT

function find_existing_files() {
    echo -n 'Getting existing files ...' >&2
    # find "$path" -type f -not -name '*.part' | sort | uniq > "$existing_files"
    find "$path" -type f | sort | uniq > "$existing_files"
    echo " done: $(wc -l "$existing_files" | cut -f1 -d' ')" >&2
}

function find_torrent_files() {
    echo -n 'Getting torrent files ...' >&2
    stig lsf all -c name | sort | uniq > "$torrent_files"
    echo " done: $(wc -l "$torrent_files" | cut -f1 -d' ')" >&2
}

find_existing_files
find_torrent_files

echo
echo "Orphaned files:"
comm -23 "$existing_files" "$torrent_files"

echo
echo "Orphaned directories:"
find "$path" -type d -empty
Czechball commented 1 year ago

That's great, thank you! I'll definitely try this out.