From b306d8e3e9aa6f1d697ba1ddddd4359be714e649 Mon Sep 17 00:00:00 2001 From: importepeu Date: Fri, 24 Aug 2018 15:44:20 +0200 Subject: [PATCH 1/2] Update file.py Change file.touch management to allow user to specify atime or mtime values of '0' to touch file with Unix epoch time 1970-01-01 01:00:00.000000000. Only positive value for atime and mtime was allowed. --- salt/modules/file.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 56e99e8e2566..8f7f20619186 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -3189,11 +3189,11 @@ def touch(name, atime=None, mtime=None): with salt.utils.files.fopen(name, 'a'): pass - if not atime and not mtime: + if atime is None and mtime is None: times = None - elif not mtime and atime: + elif mtime is None and atime is not None: times = (atime, time.time()) - elif not atime and mtime: + elif atime is None and mtime is not None: times = (time.time(), mtime) else: times = (atime, mtime) From 059c75488d95a04b4d109bb65e567d751a76a0aa Mon Sep 17 00:00:00 2001 From: importepeu Date: Wed, 5 Sep 2018 15:05:41 +0200 Subject: [PATCH 2/2] Update touch function doc Add some documentation about possible values, particularly what time will be used when setting atime or mtime to 0 or when unset them. --- salt/modules/file.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 8f7f20619186..9cf972d7ce9e 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -3168,9 +3168,13 @@ def touch(name, atime=None, mtime=None): simply update the atime and mtime if it already does. atime: - Access time in Unix epoch time + Access time in Unix epoch time. Set it to 0 to set atime of the + file with Unix date of birth. If this parameter isn't set, atime + will be set with current time. mtime: - Last modification in Unix epoch time + Last modification in Unix epoch time. Set it to 0 to set mtime of + the file with Unix date of birth. If this parameter isn't set, + mtime will be set with current time. CLI Example: