From b0c1d9a111696fd1f4b8d6d79e472047d53c8957 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 6 Jun 2016 01:07:53 +0300 Subject: [PATCH] Set timestamp for the downloaded book --- m_librarian/download.py | 5 ++++- scripts/ml-search.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/m_librarian/download.py b/m_librarian/download.py index 817f736..361f7aa 100755 --- a/m_librarian/download.py +++ b/m_librarian/download.py @@ -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)) diff --git a/scripts/ml-search.py b/scripts/ml-search.py index 18004fd..b257084 100755 --- a/scripts/ml-search.py +++ b/scripts/ml-search.py @@ -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: -- 2.39.5