Skip to content

Commit

Permalink
More mtime/fileobj bugfixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjake committed Jan 26, 2017
1 parent 5ca05a2 commit c89babf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
15 changes: 15 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
Release History
---------------

1.4.0 (2017-01-26)
++++++++++++++++++

**Bugfixes**

- Another bugfix for setting mtime correctly after ``fileobj`` functionality was added to ``ia download``.

1.3.0 (2017-01-26)
++++++++++++++++++

**Bugfixes**

- Fixed bug where download was trying to set mtime, even when ``fileobj`` was set to ``True``
(e.g. ``ia download <id> <file> --stdout``).

1.2.0 (2017-01-26)
++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion internetarchive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from __future__ import absolute_import

__title__ = 'internetarchive'
__version__ = '1.2.0'
__version__ = '1.4.0'
__author__ = 'Jacob M. Johnson'
__license__ = 'AGPL 3'
__copyright__ = 'Copyright (C) 2012-2016 Internet Archive'
Expand Down
7 changes: 5 additions & 2 deletions internetarchive/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def download(self, file_path=None, verbose=None, silent=None, ignore_existing=No
checksum = False if checksum is None else checksum
retries = 2 if not retries else retries
ignore_errors = False if not ignore_errors else ignore_errors
if (fileobj and silent is None) or silent is not None:
if (fileobj and silent is None) or silent is not False:
silent = True
else:
silent = False
Expand Down Expand Up @@ -250,8 +250,11 @@ def download(self, file_path=None, verbose=None, silent=None, ignore_existing=No
raise exc

# Set mtime with mtime from files.xml.
if not fileobj:
try:
os.utime(file_path, (0, self.mtime))
except OSError:
# Probably file-like object, e.g. sys.stdout.
pass

msg = 'downloaded {0}/{1} to {2}'.format(self.identifier,
self.name,
Expand Down

0 comments on commit c89babf

Please sign in to comment.