Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
duniter-gva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
modules
duniter-gva
Commits
d1830a78
Commit
d1830a78
authored
4 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
feat(indexer): add extension .bin.gz to blocks chunks files
parent
5ae008dc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#12472
passed
4 years ago
Stage: tests
Stage: quality
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
indexer/src/blocks_chunks.rs
+10
-2
10 additions, 2 deletions
indexer/src/blocks_chunks.rs
with
10 additions
and
2 deletions
indexer/src/blocks_chunks.rs
+
10
−
2
View file @
d1830a78
...
...
@@ -19,6 +19,8 @@ use flate2::write::ZlibEncoder;
use
flate2
::
Compression
;
const
CHUNK_SIZE
:
u32
=
4_096
;
const
CHUNK_FILE_PREFIX
:
&
str
=
"_"
;
const
CHUNK_FILE_EXT
:
&
str
=
".bin.gz"
;
pub
fn
apply_block_blocks_chunk
<
B
:
Backend
>
(
block
:
&
DubpBlockV10
,
...
...
@@ -60,7 +62,10 @@ fn read_and_remove_compressed_chunk(
chunk_index
:
u32
,
chunks_folder_path
:
&
Path
,
)
->
std
::
io
::
Result
<
Option
<
Vec
<
u8
>>>
{
let
file_path
=
chunks_folder_path
.join
(
format!
(
"_{}"
,
chunk_index
));
let
file_path
=
chunks_folder_path
.join
(
format!
(
"{}{}{}"
,
CHUNK_FILE_PREFIX
,
chunk_index
,
CHUNK_FILE_EXT
));
if
!
file_path
.exists
()
{
return
Ok
(
None
);
}
...
...
@@ -86,7 +91,10 @@ fn write_and_compress_chunk_in_file(
if
!
chunks_folder_path
.exists
()
{
std
::
fs
::
create_dir
(
chunks_folder_path
)
?
;
}
let
file
=
std
::
fs
::
File
::
create
(
chunks_folder_path
.join
(
format!
(
"_{}"
,
chunk_index
)))
?
;
let
file
=
std
::
fs
::
File
::
create
(
chunks_folder_path
.join
(
format!
(
"{}{}{}"
,
CHUNK_FILE_PREFIX
,
chunk_index
,
CHUNK_FILE_EXT
)))
?
;
let
mut
e
=
ZlibEncoder
::
new
(
file
,
Compression
::
new
(
3
));
e
.write_all
(
chunk
)
?
;
e
.finish
()
?
;
...
...
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