binhex / arch-rtorrentvpn

Docker build script for Arch Linux base with ruTorrent, rTorrent, autodl-irssi, Privoxy and OpenVPN
GNU General Public License v3.0
238 stars 35 forks source link

Disk space (with Pyrocore) #164

Closed bonny1992 closed 3 years ago

bonny1992 commented 3 years ago

Hello everyone!

I'm trying to configure rtorrent/rutorrent to auto stop and auto resume watching free disk space (for instance, when it goes below 150 gb, it stops, then above 150, starts again).

The auto stop feature works great with this command:

schedule2 = monitor_diskspace, 15, 60, ((close_low_diskspace,150000M))

but as soon as I free up some space, the torrents are still in "stopped" state.

If I start manually them, they go into a "paused" state, and never start. If I effectively want them to start, I have to right click them and "force recheck".

What I'd like is to have rtorrent start again automatically.

Here's what happens:

Downloading > space goes below 150 gb > rtorrent stops all the torrents not in seeding > I clear the space > we are above 350 gb of free space > torrents still in "stopped" state > I select all the "downloading" ones > Start them > Right click and "force recheck" > Torrents working again

I tested this using

head -c 350G /dev/zero > test.txt

for creating a 350 gb file, deleted it after rtorrent stopped all the torrents, waited for an hour, watched rtutorrent. The torrents were still in a stopped state.

Rummaging through the files created by the image, I found this piece of code:

...
# Disk space check
def has_room(obj):
    "Check disk space."
    pathname = obj.path
    try:
        if pathname and not os.path.exists(pathname):
            pathname = os.path.dirname(pathname)
        if pathname and os.path.exists(pathname):
            stats = os.statvfs(pathname)
            return (stats.f_bavail * stats.f_frsize - int(diskspace_threshold_mb) * 1024**2
                > obj.size * (1.0 - obj.done / 100.0))
        else:
            return None
    except UnicodeEncodeError as exc:
        raise ValueError('Problematic filename %r: %s' % (pathname, exc))

yield engine.DynamicField(engine.untyped, "has_room",
    "check whether the download will fit on its target device",
    matcher=matching.BoolFilter, accessor=has_room,
    formatter=lambda val: "OK" if val else "??" if val is None else "NO")
globals().setdefault("diskspace_threshold_mb", "500")
...

And I changed the value from 500 to 150000 but it seems to be ignored in any case.

Am I doing something wrong?

Anyone can help me? Thank you in advance!

Edit: the code above seems to be from https://pyrocore.readthedocs.io/en/latest/custom.html#only-start-items-that-you-have-disk-space-for

bonny1992 commented 3 years ago

After entering the container with the command docker exec -it rtorrentvpn bash

and running

touch /config/pyrocore/run/pyrotorque
sudo -u nobody pyrotorque --config-dir=/config/pyrocore

It says Fault -503: 'Could not find view.' and points to this xml: https://controlc.com/003897b3

bonny1992 commented 3 years ago

My torque.ini: https://controlc.com/76ecf9e5 My config.py: https://controlc.com/e87caa01 My .rtorrent.rc: https://controlc.com/11ecb21f

bonny1992 commented 3 years ago

I "solved" this writing this script:

https://gist.github.com/bonny1992/3bed65f4bcdc372b833b65442995c71a