]> git.phdru.name Git - extfs.d.git/blobdiff - torrent
Update docs on date/time display
[extfs.d.git] / torrent
diff --git a/torrent b/torrent
index cc9dc3dcc2d46691f63591888777f0858123cdc0..a6685f0d3165d8627d611fa4105e4043ab5f5076 100755 (executable)
--- 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)