|
|
@ -374,6 +374,8 @@ def get_timestamp_for_time(formatted_time, time_format):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_timestamp_for_file(path, mtime, atime, diff=None):
|
|
|
|
def update_timestamp_for_file(path, mtime, atime, diff=None):
|
|
|
|
|
|
|
|
b_path = to_bytes(path, errors='surrogate_or_strict')
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# When mtime and atime are set to 'now', rely on utime(path, None) which does not require ownership of the file
|
|
|
|
# When mtime and atime are set to 'now', rely on utime(path, None) which does not require ownership of the file
|
|
|
|
# https://github.com/ansible/ansible/issues/50943
|
|
|
|
# https://github.com/ansible/ansible/issues/50943
|
|
|
@ -382,8 +384,8 @@ def update_timestamp_for_file(path, mtime, atime, diff=None):
|
|
|
|
# not be updated. Just use the current time for the diff values
|
|
|
|
# not be updated. Just use the current time for the diff values
|
|
|
|
mtime = atime = time.time()
|
|
|
|
mtime = atime = time.time()
|
|
|
|
|
|
|
|
|
|
|
|
previous_mtime = os.stat(path).st_mtime
|
|
|
|
previous_mtime = os.stat(b_path).st_mtime
|
|
|
|
previous_atime = os.stat(path).st_atime
|
|
|
|
previous_atime = os.stat(b_path).st_atime
|
|
|
|
|
|
|
|
|
|
|
|
set_time = None
|
|
|
|
set_time = None
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -391,8 +393,8 @@ def update_timestamp_for_file(path, mtime, atime, diff=None):
|
|
|
|
if mtime is None and atime is None:
|
|
|
|
if mtime is None and atime is None:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
previous_mtime = os.stat(path).st_mtime
|
|
|
|
previous_mtime = os.stat(b_path).st_mtime
|
|
|
|
previous_atime = os.stat(path).st_atime
|
|
|
|
previous_atime = os.stat(b_path).st_atime
|
|
|
|
|
|
|
|
|
|
|
|
if mtime is None:
|
|
|
|
if mtime is None:
|
|
|
|
mtime = previous_mtime
|
|
|
|
mtime = previous_mtime
|
|
|
@ -410,7 +412,7 @@ def update_timestamp_for_file(path, mtime, atime, diff=None):
|
|
|
|
|
|
|
|
|
|
|
|
set_time = (atime, mtime)
|
|
|
|
set_time = (atime, mtime)
|
|
|
|
|
|
|
|
|
|
|
|
os.utime(path, set_time)
|
|
|
|
os.utime(b_path, set_time)
|
|
|
|
|
|
|
|
|
|
|
|
if diff is not None:
|
|
|
|
if diff is not None:
|
|
|
|
if 'before' not in diff:
|
|
|
|
if 'before' not in diff:
|
|
|
|