Пример #1
0
def stale():
    base = get_conf()['rtorrent']['downloads']
    resident = set(glob.glob(os.path.join(base, '*')))
    current = set([os.path.join(base, res['name'])
                   for res in rtorrent.torrents('main', 'get_name')])
    stale = resident - current

    for path in stale:
        # should never happen
        if path == base: continue

        if os.path.isdir(path):
            shutil.rmtree(path)
        else:
            os.remove(path)
Пример #2
0
def prune():
    ts = rtorrent.torrents('main', 'get_hash', 'get_custom=metadata')
    expired = []

    for t in ts:
        metadata = rtorrent.decode_metadata(t['metadata'])

        if metadata['locks']: continue

        date = parser.parse(metadata['date']).replace(tzinfo=None)
        # TODO: conf expiration
        expires_at = date + datetime.timedelta(weeks=2)
        now = datetime.datetime.utcnow()

        if now > expires_at and not metadata['locks']:
            expired.append(t['hash'])

    rtorrent.erase(expired)