summaryrefslogtreecommitdiff
path: root/swiftclient/service.py
diff options
context:
space:
mode:
authorChristopher Bartz <bartz@dkrz.de>2017-07-06 17:30:48 +0200
committerTim Burke <tim.burke@gmail.com>2017-07-06 10:19:12 -0700
commitcde73c196d4f161b227fb924cd59cf02eaa33c03 (patch)
tree6e4314a1d68974f4f00ab90b7162ab83e33f9e6b /swiftclient/service.py
parent1d57403668815ab8cef9d6598c06bf1c7e5355c0 (diff)
downloadpython-swiftclient-cde73c196d4f161b227fb924cd59cf02eaa33c03.tar.gz
Option to ignore mtime metadata entry.
Currently, the swiftclient upload command passes a custom metadata header for each object (called object-meta-mtime), whose value is the current UNIX timestamp. When downloading such an object with the swiftclient, the mtime header is parsed and passed as the atime and mtime for the newly created file. There are use-cases where this is not desired, for example when using tmp or scratch directories in which files older than a specific date are deleted. This commit provides a boolean option for ignoring the mtime header. Change-Id: If60b389aa910c6f1969b999b5d3b6d0940375686
Diffstat (limited to 'swiftclient/service.py')
-rw-r--r--swiftclient/service.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/swiftclient/service.py b/swiftclient/service.py
index b9b843e..5a43bf2 100644
--- a/swiftclient/service.py
+++ b/swiftclient/service.py
@@ -203,6 +203,7 @@ _default_local_options = {
'shuffle': False,
'destination': None,
'fresh_metadata': False,
+ 'ignore_mtime': False,
}
POLICY = 'X-Storage-Policy'
@@ -1240,7 +1241,8 @@ class SwiftService(object):
bytes_read = obj_body.bytes_read()
if fp is not None:
fp.close()
- if 'x-object-meta-mtime' in headers and not no_file:
+ if ('x-object-meta-mtime' in headers and not no_file
+ and not options['ignore_mtime']):
try:
mtime = float(headers['x-object-meta-mtime'])
except ValueError: