]> git.phdru.name Git - m_librarian.git/commitdiff
Set timestamp for the downloaded book
authorOleg Broytman <phd@phdru.name>
Sun, 5 Jun 2016 22:07:53 +0000 (01:07 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 5 Jun 2016 22:07:53 +0000 (01:07 +0300)
m_librarian/download.py
scripts/ml-search.py

index 817f736352907d7fb9ab7d50effbd7b24f21139e..361f7aa735549a783e80a0f4adcef6ae67464f43 100755 (executable)
@@ -1,6 +1,7 @@
 #! /usr/bin/env python
 
 import os
+from time import mktime
 from shutil import copyfileobj
 from zipfile import ZipFile
 from .config import get_config
@@ -11,7 +12,7 @@ __all__ = ['download']
 _library_path = None
 
 
-def download(archive, filename, path=None):
+def download(archive, filename, date, path=None):
     if path is None:
         global _library_path
         if _library_path is None:
@@ -25,3 +26,5 @@ def download(archive, filename, path=None):
     outfile.close()
     infile.close()
     zf.close()
+    dt = mktime(date.timetuple())
+    os.utime(filename, (dt, dt))
index 18004fd71ad533e1f8262190eb075ec01af2ec9f..b257084a749d03a487f2f0889b656b57639d35dc 100755 (executable)
@@ -147,7 +147,7 @@ def _search_books(case_sensitive, search_type, args):
             sys.exit(1)
         book = books[0]
         download(book.archive, '%s.%s' % (book.file, book.extension.name),
-                 args.path)
+                 book.date, args.path)
         return
     count = 0
     for book in books: