Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.toolbox
Commits
aec0ea6f
Commit
aec0ea6f
authored
Nov 02, 2018
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
read file by chunk for calculating sha256
parent
e176156e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
slapos/resilient/runner_exporter.py
slapos/resilient/runner_exporter.py
+12
-6
No files found.
slapos/resilient/runner_exporter.py
View file @
aec0ea6f
...
...
@@ -23,6 +23,14 @@ os.environ['LC_ALL'] = 'C'
os
.
umask
(
0o77
)
def
read_file_by_chunk
(
path
,
chunk_size
=
1024
*
10
):
with
open
(
path
,
'rb'
)
as
f
:
chunk
=
f
.
read
(
chunk_size
)
while
chunk
:
yield
chunk
chunk
=
f
.
read
(
chunk_size
)
@
contextmanager
def
CwdContextManager
(
path
):
"""
...
...
@@ -128,12 +136,10 @@ def getExcludePathList(path):
def
getSha256Sum
(
file_path
):
# TODO : introduce reading by chunk,
# otherwise reading backup files of 5Gb
# may crash the server.
# XXX : Use os.open ?
with
open
(
file_path
,
'rb'
)
as
f
:
return
sha256
(
f
.
read
()).
hexdigest
()
hash_sum
=
sha256
()
for
chunk
in
read_file_by_chunk
(
file_path
):
hash_sum
.
update
(
chunk
)
return
hash_sum
.
hexdigest
()
def
synchroniseRunnerConfigurationDirectory
(
config
,
backup_path
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment