X-Git-Url: https://git.phdru.name/?p=extfs.d.git;a=blobdiff_plain;f=torrent;h=a6685f0d3165d8627d611fa4105e4043ab5f5076;hp=cc9dc3dcc2d46691f63591888777f0858123cdc0;hb=1c36a84abf307fa032c2b720994f54a36a41924c;hpb=f8149878b4b42033610eef9b305e6b71c2e5f549 diff --git a/torrent b/torrent index cc9dc3d..a6685f0 100755 --- a/torrent +++ b/torrent @@ -27,8 +27,11 @@ contents of these files are taken from the corresponding fields in the torrent metafile. The script doesn't check if the torrent consists of a .META file or directory (quite unlikely). -Date/time for all files is set to midnight of the 1st January of the current -year. The filesystem is, naturally, read-only. +Date/time for all directories/files is set to the value of 'creation date' +field, if it exists; if not date/time is set to the last modification time of +the torrent file itself. + +The filesystem is, naturally, read-only. """ @@ -38,7 +41,7 @@ __copyright__ = "Copyright (C) 2010-2015 PhiloSoft Design" __license__ = "GPL" -from os.path import getmtime +from os.path import dirname, getmtime import sys from time import localtime, asctime from eff_bdecode import decode @@ -182,10 +185,19 @@ def mctorrent_list(): if 'piece length' in info: meta.append(('.META/piece length', len(str(info['piece length'])))) + paths += meta + dirs = set() + for name, size in paths: + if '/' in name: + dirs.add(dirname(name)) + if not dt: dt = decode_datetime(getmtime(sys.argv[2])) - for name, size in paths + meta: + for name in sorted(dirs): + print "dr-xr-xr-x 1 user group 0 %s %s" % (dt, name) + + for name, size in sorted(paths): print "-r--r--r-- 1 user group %d %s %s" % (size, dt, name)