From f8149878b4b42033610eef9b305e6b71c2e5f549 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 8 Jul 2015 21:50:44 +0300 Subject: [PATCH] Torrent VFS: version 1.2.3 Set files date/time to the content of ".META/creation date" file if it exists or to the last modification time of the torrent file itself. --- torrent | 25 +++++++++++++++++-------- torrent-ANNOUNCE | 4 ++++ torrent-ChangeLog | 5 +++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/torrent b/torrent index 65c8b61..cc9dc3d 100755 --- a/torrent +++ b/torrent @@ -32,13 +32,15 @@ year. The filesystem is, naturally, read-only. """ -__version__ = "1.2.2" +__version__ = "1.2.3" __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2010-2015 PhiloSoft Design" __license__ = "GPL" +from os.path import getmtime import sys +from time import localtime, asctime from eff_bdecode import decode try: @@ -105,6 +107,7 @@ def mctorrent_list(): name = info['name'] name_utf8 = info.get('name.utf-8', None) + dt = None if 'files' in info: files = info['files'] paths = [] @@ -163,7 +166,9 @@ def mctorrent_list(): elif name == 'codepage': data = str(torrent[name]) elif name == 'creation date': - data = decode_datetime(torrent[name]) + dt = torrent[name] + data = decode_datetime_asc(dt) + dt = decode_datetime(dt) elif name == 'nodes': data = ['%s:%s' % (host, port) for host, port in torrent[name]] data = '\n'.join(data) @@ -177,8 +182,11 @@ def mctorrent_list(): if 'piece length' in info: meta.append(('.META/piece length', len(str(info['piece length'])))) + if not dt: + dt = decode_datetime(getmtime(sys.argv[2])) + for name, size in paths + meta: - print "-r--r--r-- 1 user group %d Jan 1 00:00 %s" % (size, name) + print "-r--r--r-- 1 user group %d %s %s" % (size, dt, name) def mctorrent_copyout(): @@ -200,7 +208,7 @@ def mctorrent_copyout(): elif name == 'codepage': data = str(torrent[name]) elif name == 'creation date': - data = decode_datetime(torrent[name]) + data = decode_datetime_asc(torrent[name]) elif name == 'nodes': data = ['%s:%s' % (host, port) for host, port in torrent[name]] data = '\n'.join(data) @@ -262,11 +270,12 @@ def decode_torrent(): torrent_error(error_str) +def decode_datetime_asc(dt): + return asctime(localtime(float(dt))) + def decode_datetime(dt): - from time import localtime, asctime - the_time = float(dt) - l_now = localtime(the_time) - return asctime(l_now) + Y, m, d, H, M = localtime(float(dt))[0:5] + return "%02d-%02d-%d %02d:%02d" % (m, d, Y, H, M) def decode_announce_list(announce): return '\n'.join(l[0] for l in announce) diff --git a/torrent-ANNOUNCE b/torrent-ANNOUNCE index eeb1223..2102e91 100644 --- a/torrent-ANNOUNCE +++ b/torrent-ANNOUNCE @@ -7,6 +7,10 @@ Midnight Commander. WHAT'S NEW +Version 1.2.3 (2015-07-08) + Set files date/time to the content of ".META/creation date" file +if it exists or to the last modification time of the torrent file itself. + Version 1.2.2 (2015-01-10) Changed link to installation instructions. diff --git a/torrent-ChangeLog b/torrent-ChangeLog index a90e1e2..9bcf476 100644 --- a/torrent-ChangeLog +++ b/torrent-ChangeLog @@ -1,3 +1,8 @@ +Version 1.2.3 (2015-07-08) + + Set files date/time to the content of ".META/creation date" file +if it exists or to the last modification time of the torrent file itself. + Version 1.2.2 (2015-01-10) Changed link to installation instructions. -- 2.39.2