summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-06-10 08:26:54 +0200
committerJürg Billeter <j@bitron.ch>2020-06-10 11:22:04 +0200
commit0df31342e9c3c32af55f0ea114a60ab858356173 (patch)
tree869a7c60db613e9f806da61fd1448156d0cf665f /src
parentc0bc6cfa9b2461e86ff39fa157e10cc9ef77d199 (diff)
downloadbuildstream-juerg/object-file-mode.tar.gz
cascache.py: Fix file modes in checkout()juerg/object-file-mode
Do not copy file mode from casd object file. Do not change non-executable mode bits if file is executable.
Diffstat (limited to 'src')
-rw-r--r--src/buildstream/_cas/cascache.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index 9394ac5b2..6b2f0d1a4 100644
--- a/src/buildstream/_cas/cascache.py
+++ b/src/buildstream/_cas/cascache.py
@@ -241,21 +241,20 @@ class CASCache:
if can_link and mtime is None:
utils.safe_link(self.objpath(filenode.digest), fullpath)
else:
- utils.safe_copy(self.objpath(filenode.digest), fullpath)
+ utils.safe_copy(self.objpath(filenode.digest), fullpath, copystat=False)
if mtime is not None:
utils._set_file_mtime(fullpath, mtime)
if filenode.is_executable:
- os.chmod(
- fullpath,
- stat.S_IRUSR
- | stat.S_IWUSR
- | stat.S_IXUSR
- | stat.S_IRGRP
- | stat.S_IXGRP
- | stat.S_IROTH
- | stat.S_IXOTH,
- )
+ st = os.stat(fullpath)
+ mode = st.st_mode
+ if mode & stat.S_IRUSR:
+ mode |= stat.S_IXUSR
+ if mode & stat.S_IRGRP:
+ mode |= stat.S_IXGRP
+ if mode & stat.S_IROTH:
+ mode |= stat.S_IXOTH
+ os.chmod(fullpath, mode)
for dirnode in directory.directories:
fullpath = os.path.join(dest, dirnode.name)