Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildstream
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
BuildStream
buildstream
Commits
f217f058
Commit
f217f058
authored
6 years ago
by
Raoul Hidalgo Charman
Browse files
Options
Downloads
Patches
Plain Diff
utils.py: Add message digest function
Get cascache.py to use this
parent
f7581026
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
buildstream/_artifactcache/cascache.py
+1
-4
1 addition, 4 deletions
buildstream/_artifactcache/cascache.py
buildstream/utils.py
+17
-0
17 additions, 0 deletions
buildstream/utils.py
with
18 additions
and
4 deletions
buildstream/_artifactcache/cascache.py
+
1
−
4
View file @
f217f058
...
...
@@ -427,10 +427,7 @@ class CASCache():
def
push_message
(
self
,
remote
,
message
):
message_buffer
=
message
.
SerializeToString
()
message_sha
=
hashlib
.
sha256
(
message_buffer
)
message_digest
=
remote_execution_pb2
.
Digest
()
message_digest
.
hash
=
message_sha
.
hexdigest
()
message_digest
.
size_bytes
=
len
(
message_buffer
)
message_digest
=
utils
.
_message_digest
(
message_buffer
)
remote
.
init
()
...
...
This diff is collapsed.
Click to expand it.
buildstream/utils.py
+
17
−
0
View file @
f217f058
...
...
@@ -41,6 +41,7 @@ import psutil
from
.
import
_signals
from
._exceptions
import
BstError
,
ErrorDomain
from
._protos.build.bazel.remote.execution.v2
import
remote_execution_pb2
# The magic number for timestamps: 2011-11-11 11:11:11
_magic_timestamp
=
calendar
.
timegm
([
2011
,
11
,
11
,
11
,
11
,
11
])
...
...
@@ -1242,3 +1243,19 @@ def _deduplicate(iterable, key=None):
def
_get_link_mtime
(
path
):
path_stat
=
os
.
lstat
(
path
)
return
path_stat
.
st_mtime
# message_digest()
#
# Args:
# message_buffer (str): String to create digest of
#
# Returns:
# (remote_execution_pb2.Digest): Content digest
#
def
_message_digest
(
message_buffer
):
sha
=
hashlib
.
sha256
(
message_buffer
)
digest
=
remote_execution_pb2
.
Digest
()
digest
.
hash
=
sha
.
hexdigest
()
digest
.
size_bytes
=
len
(
message_buffer
)
return
digest
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment