Commit 542c9935 authored by Leo Le Bouter's avatar Leo Le Bouter

Move back to JSON from MsgPack, change upload module in ERP5

The Python msgpack library does not deserialize MsgPack data
created with Rust's rmp-serde well.

Upload to Computer Metadata Snapshot module recently created for
ERP5.
parent 6d98aefb
This diff is collapsed.
...@@ -20,8 +20,9 @@ nix = "0.18.0" ...@@ -20,8 +20,9 @@ nix = "0.18.0"
serde = { version = "1.0.115", features = ["derive"] } serde = { version = "1.0.115", features = ["derive"] }
base64 = "0.12.3" base64 = "0.12.3"
rayon = "1.3.1" rayon = "1.3.1"
serde_json = "1.0.57"
[profile.release] [profile.release]
opt-level = 'z' opt-level = 'z'
lto = true lto = true
codegen-units = 1 codegen-units = 1
\ No newline at end of file
...@@ -64,9 +64,9 @@ impl From<nix::sys::stat::FileStat> for FileStat { ...@@ -64,9 +64,9 @@ impl From<nix::sys::stat::FileStat> for FileStat {
#[derive(Default, Debug, Serialize)] #[derive(Default, Debug, Serialize)]
struct Tree { struct Tree {
childs: HashMap<OsString, Tree>, childs: HashMap<String, Tree>,
stat: Option<FileStat>, stat: Option<FileStat>,
xattrs: HashMap<OsString, Option<Vec<u8>>>, xattrs: HashMap<String, Option<Vec<u8>>>,
posix_acls: Option<String>, posix_acls: Option<String>,
ignored: bool, ignored: bool,
symlink_target: Option<OsString>, symlink_target: Option<OsString>,
...@@ -131,7 +131,7 @@ fn construct_fs_tree( ...@@ -131,7 +131,7 @@ fn construct_fs_tree(
xattrs: match xattr::list(&entry.path()) { xattrs: match xattr::list(&entry.path()) {
Ok(xattrs) => xattrs Ok(xattrs) => xattrs
.filter_map(|name| match xattr::get(&entry.path(), &name) { .filter_map(|name| match xattr::get(&entry.path(), &name) {
Ok(xattr) => Some((name, xattr)), Ok(xattr) => Some((name.to_str().unwrap().to_string(), xattr)),
_ => None, _ => None,
}) })
.collect(), .collect(),
...@@ -198,7 +198,9 @@ fn construct_fs_tree( ...@@ -198,7 +198,9 @@ fn construct_fs_tree(
{ {
let mut locked = cur_tree.lock().unwrap(); let mut locked = cur_tree.lock().unwrap();
locked.childs.insert(entry.file_name(), tree); locked
.childs
.insert(entry.file_name().to_str().unwrap().to_string(), tree);
} }
} }
_ => {} _ => {}
...@@ -235,9 +237,9 @@ fn upload_to_erp5<R: Read + Send + 'static>( ...@@ -235,9 +237,9 @@ fn upload_to_erp5<R: Read + Send + 'static>(
let resp = client let resp = client
.get(&format!("{}/portal_contributions/newContent", base_url)) .get(&format!("{}/portal_contributions/newContent", base_url))
.query(&[ .query(&[
("portal_type", "File"), ("portal_type", "Computer Metadata Snapshot"),
("filename", &format!("{}.metadata", &reference)), ("filename", &format!("{}.metadata", &reference)),
("container_path", "document_module"), ("container_path", "computer_metadata_snapshot_module"),
("data", ""), ("data", ""),
]) ])
.send()?; .send()?;
...@@ -342,7 +344,7 @@ fn main() -> Result<()> { ...@@ -342,7 +344,7 @@ fn main() -> Result<()> {
)?, )?,
}; };
let packed = rmp_serde::encode::to_vec_named(&snapshot)?; let packed = serde_json::to_vec(&snapshot)?;
let packed_size = packed.len() as u64; let packed_size = packed.len() as u64;
upload_to_erp5( upload_to_erp5(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment