Browse Source

PR #244 - Merge branch 'fix_atime' into merge

Thomas Waldmann 10 years ago
parent
commit
f31897bb1f
1 changed files with 3 additions and 1 deletions
  1. 3 1
      attic/archive.py

+ 3 - 1
attic/archive.py

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