PR #244 - Merge branch 'fix_atime' into merge

This commit is contained in:
Thomas Waldmann 2015-03-20 01:43:04 +01:00
commit f31897bb1f
1 changed files with 3 additions and 1 deletions

View File

@ -450,7 +450,8 @@ class Archive:
return open(p, 'rb')
def open_noatime_if_owner(p, s):
if s.st_uid == euid:
if euid == 0 or s.st_uid == euid:
# we are root or owner of file
return os.fdopen(os.open(p, flags_noatime), 'rb')
else:
return open(p, 'rb')
@ -463,6 +464,7 @@ class Archive:
fo = open(p, 'rb')
# Yes, it was -- otherwise the above line would have thrown
# another exception.
nonlocal euid
euid = os.geteuid()
# So in future, let's check whether the file is owned by us
# before attempting to use O_NOATIME.