From c4be36fc71dd5829b55b3e0fc5f11c62fcad3a16 Mon Sep 17 00:00:00 2001 From: importepeu Date: Thu, 17 Sep 2020 14:09:13 +0200 Subject: [PATCH] Update file.py Allow user to use Unix birth of time --- salt/modules/file.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 5b8690fa6ad6..5c697d7bd555 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -3512,9 +3512,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: @@ -3533,11 +3537,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)