Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
metadata-collect-agent
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
metadata-collect-agent
Commits
fe5ff88b
Commit
fe5ff88b
authored
Jun 07, 2021
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
write to file
parent
46de40d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
44 deletions
+4
-44
src/main.rs
src/main.rs
+4
-44
No files found.
src/main.rs
View file @
fe5ff88b
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
blocking
::
multipart
;
use
clap
::{
App
,
Arg
};
use
clap
::{
App
,
Arg
};
use
multipart
::
Part
;
use
rayon
::
prelude
::
*
;
use
rayon
::
prelude
::
*
;
use
reqwest
::{
use
reqwest
::{
blocking
::{
self
,
Client
},
blocking
::{
self
,
Client
},
...
@@ -217,17 +215,6 @@ fn construct_fs_tree(
...
@@ -217,17 +215,6 @@ fn construct_fs_tree(
Ok
(
cur_tree
)
Ok
(
cur_tree
)
}
}
fn
upload_to_erp5
<
R
:
Read
+
Send
+
'static
>
(
reader
:
R
,
size
:
u64
,
base_url
:
&
str
,
username
:
&
str
,
password
:
&
str
,
reference
:
&
str
,
)
->
Result
<
()
>
{
Part
::
reader_with_length
(
reader
,
size
)
.file_name
(
format!
(
"/var/log/metadata_collect.log"
));
Ok
(())
}
fn
main
()
->
Result
<
()
>
{
fn
main
()
->
Result
<
()
>
{
let
m
=
App
::
new
(
"metadata-collect-agent"
)
let
m
=
App
::
new
(
"metadata-collect-agent"
)
...
@@ -236,22 +223,6 @@ fn main() -> Result<()> {
...
@@ -236,22 +223,6 @@ fn main() -> Result<()> {
.required
(
true
)
.required
(
true
)
.takes_value
(
true
)
.takes_value
(
true
)
.multiple
(
false
),
.multiple
(
false
),
Arg
::
with_name
(
"erp5-user"
)
.takes_value
(
true
)
.multiple
(
false
)
.required
(
true
),
Arg
::
with_name
(
"erp5-pass"
)
.takes_value
(
true
)
.multiple
(
false
)
.required
(
true
),
Arg
::
with_name
(
"erp5-file-reference"
)
.takes_value
(
true
)
.multiple
(
false
)
.required
(
true
),
Arg
::
with_name
(
"erp5-base-url"
)
.takes_value
(
true
)
.multiple
(
false
)
.required
(
true
),
Arg
::
with_name
(
"ignored-dirs"
)
Arg
::
with_name
(
"ignored-dirs"
)
.takes_value
(
true
)
.takes_value
(
true
)
.multiple
(
true
)
.multiple
(
true
)
...
@@ -283,21 +254,10 @@ fn main() -> Result<()> {
...
@@ -283,21 +254,10 @@ fn main() -> Result<()> {
&
ignored_dirs
,
&
ignored_dirs
,
)
?
,
)
?
,
};
};
let
packed
=
serde_json
::
to_string
(
&
snapshot
)
?
;
let
packed
=
serde_json
::
to_vec
(
&
snapshot
)
?
;
for
s
in
packed
.split
(
":{"
){
let
packed_size
=
packed
.len
()
as
u64
;
file
.write_all
((
s
.to_owned
()
+
"
\n
"
)
.as_bytes
());
}
upload_to_erp5
(
Cursor
::
new
(
packed
),
packed_size
,
m
.value_of
(
"erp5-base-url"
)
.unwrap
(),
m
.value_of
(
"erp5-user"
)
.unwrap
(),
m
.value_of
(
"erp5-pass"
)
.unwrap
(),
m
.value_of
(
"erp5-file-reference"
)
.unwrap
(),
)
?
;
writeln!
(
file
,
"[200202: end]"
);
writeln!
(
file
,
"[2020222: end]"
);
let
_
result
=
child
.wait
()
.unwrap
();
let
_
result
=
child
.wait
()
.unwrap
();
Ok
(())
Ok
(())
...
...
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