Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to users to touch file with Unix date of birth #49310

Merged
merged 2 commits into from
Sep 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions salt/modules/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -3189,11 +3193,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)
Expand Down