Private GIT

Skip to content
Snippets Groups Projects
Commit f5b22c30 authored by Nic Wolfe's avatar Nic Wolfe
Browse files

I guess it doesn't hurt...

parent 173cd89e
No related branches found
No related tags found
No related merge requests found
...@@ -414,11 +414,26 @@ def chmodAsParent(childPath): ...@@ -414,11 +414,26 @@ def chmodAsParent(childPath):
parentPath = ek.ek(os.path.dirname, childPath) parentPath = ek.ek(os.path.dirname, childPath)
parentMode = stat.S_IMODE(os.stat(parentPath)[stat.ST_MODE]) parentMode = stat.S_IMODE(os.stat(parentPath)[stat.ST_MODE])
if ek.ek(os.path.isfile, childPath):
childMode = readwriteBits(parentMode)
else:
childMode = parentMode
try: try:
os.chmod(childPath, parentMode) os.chmod(childPath, childMode)
logger.log(u"Setting permissions for %s to %o as parent directory has %o" % (childPath, parentMode, parentMode), logger.DEBUG) logger.log(u"Setting permissions for %s to %o as parent directory has %o" % (childPath, childMode, parentMode), logger.DEBUG)
except OSError: except OSError:
logger.log(u"Failed to set permission for %s to %o" % (childPath, parentMode), logger.ERROR) logger.log(u"Failed to set permission for %s to %o" % (childPath, childMode), logger.ERROR)
def readwriteBits(currentMode):
newMode = 0
for bit in [stat.S_IRUSR, stat.S_IWUSR, stat.S_IRGRP, stat.S_IWGRP, stat.S_IROTH, stat.S_IWOTH]:
if currentMode & bit:
newMode += bit
return newMode
if __name__ == '__main__': if __name__ == '__main__':
import doctest import doctest
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment