[Notes] [Git][BuildStream/buildstream][valentindavid/pull-chmod-bug-1.2] buildstream/_artifactcache/cascache.py: Set 0644 rights to pulled files



Title: GitLab

Valentin David pushed to branch valentindavid/pull-chmod-bug-1.2 at BuildStream / buildstream

Commits:

2 changed files:

Changes:

  • buildstream/_artifactcache/cascache.py
    ... ... @@ -854,6 +854,7 @@ class CASCache(ArtifactCache):
    854 854
             with tempfile.NamedTemporaryFile(dir=self.tmpdir) as f:
    
    855 855
                 self._fetch_blob(remote, digest, f)
    
    856 856
     
    
    857
    +            os.chmod(f.name, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
    
    857 858
                 added_digest = self.add_object(path=f.name, link_directly=True)
    
    858 859
                 assert added_digest.hash == digest.hash
    
    859 860
     
    
    ... ... @@ -865,6 +866,7 @@ class CASCache(ArtifactCache):
    865 866
                     f.write(data)
    
    866 867
                     f.flush()
    
    867 868
     
    
    869
    +                os.chmod(f.name, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
    
    868 870
                     added_digest = self.add_object(path=f.name, link_directly=True)
    
    869 871
                     assert added_digest.hash == digest.hash
    
    870 872
     
    

  • tests/frontend/pull.py
    1 1
     import os
    
    2 2
     import shutil
    
    3
    +import stat
    
    3 4
     import pytest
    
    4 5
     from tests.testutils import cli, create_artifact_share, generate_junction
    
    5 6
     
    
    ... ... @@ -358,3 +359,50 @@ def test_pull_missing_notifies_user(caplog, cli, tmpdir, datafiles):
    358 359
     
    
    359 360
             assert "INFO    Remote ({}) does not have".format(share.repo) in result.stderr
    
    360 361
             assert "SKIPPED Pull" in result.stderr
    
    362
    +
    
    363
    +
    
    364
    +@pytest.mark.datafiles(DATA_DIR)
    
    365
    +def test_pull_access_rights(caplog, cli, tmpdir, datafiles):
    
    366
    +    project = str(datafiles)
    
    367
    +    checkout = os.path.join(str(tmpdir), 'checkout')
    
    368
    +
    
    369
    +    # Work-around datafiles not preserving mode
    
    370
    +    os.chmod(os.path.join(project, 'files/bin-files/usr/bin/hello'), 0o0755)
    
    371
    +
    
    372
    +    with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
    
    373
    +
    
    374
    +        cli.configure({
    
    375
    +            'artifacts': {'url': share.repo, 'push': True}
    
    376
    +        })
    
    377
    +        result = cli.run(project=project, args=['build', 'compose-all.bst'])
    
    378
    +        result.assert_success()
    
    379
    +
    
    380
    +        result = cli.run(project=project, args=['checkout', '--hardlinks', '--no-integrate', 'compose-all.bst', checkout])
    
    381
    +        result.assert_success()
    
    382
    +
    
    383
    +        st = os.lstat(os.path.join(checkout, 'usr/include/pony.h'))
    
    384
    +        assert stat.S_ISREG(st.st_mode)
    
    385
    +        assert stat.S_IMODE(st.st_mode) == 0o0644
    
    386
    +
    
    387
    +        st = os.lstat(os.path.join(checkout, 'usr/bin/hello'))
    
    388
    +        assert stat.S_ISREG(st.st_mode)
    
    389
    +        assert stat.S_IMODE(st.st_mode) == 0o0755
    
    390
    +
    
    391
    +        shutil.rmtree(checkout)
    
    392
    +
    
    393
    +        artifacts = os.path.join(cli.directory, 'artifacts')
    
    394
    +        shutil.rmtree(artifacts)
    
    395
    +
    
    396
    +        result = cli.run(project=project, args=['pull', 'compose-all.bst'])
    
    397
    +        result.assert_success()
    
    398
    +
    
    399
    +        result = cli.run(project=project, args=['checkout', '--hardlinks', '--no-integrate', 'compose-all.bst', checkout])
    
    400
    +        result.assert_success()
    
    401
    +
    
    402
    +        st = os.lstat(os.path.join(checkout, 'usr/include/pony.h'))
    
    403
    +        assert stat.S_ISREG(st.st_mode)
    
    404
    +        assert stat.S_IMODE(st.st_mode) == 0o0644
    
    405
    +
    
    406
    +        st = os.lstat(os.path.join(checkout, 'usr/bin/hello'))
    
    407
    +        assert stat.S_ISREG(st.st_mode)
    
    408
    +        assert stat.S_IMODE(st.st_mode) == 0o0755



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]