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"
serde = { version = "1.0.115", features = ["derive"] }
base64 = "0.12.3"
rayon = "1.3.1"
serde_json = "1.0.57"
[profile.release]
opt-level = 'z'
lto = true
codegen-units = 1
\ No newline at end of file
codegen-units = 1
......@@ -64,9 +64,9 @@ impl From<nix::sys::stat::FileStat> for FileStat {
#[derive(Default, Debug, Serialize)]
struct Tree {
childs: HashMap<OsString, Tree>,
childs: HashMap<String, Tree>,
stat: Option<FileStat>,
xattrs: HashMap<OsString, Option<Vec<u8>>>,
xattrs: HashMap<String, Option<Vec<u8>>>,
posix_acls: Option<String>,
ignored: bool,
symlink_target: Option<OsString>,
......@@ -131,7 +131,7 @@ fn construct_fs_tree(
xattrs: match xattr::list(&entry.path()) {
Ok(xattrs) => xattrs
.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,
})
.collect(),
......@@ -198,7 +198,9 @@ fn construct_fs_tree(
{
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>(
let resp = client
.get(&format!("{}/portal_contributions/newContent", base_url))
.query(&[
("portal_type", "File"),
("portal_type", "Computer Metadata Snapshot"),
("filename", &format!("{}.metadata", &reference)),
("container_path", "document_module"),
("container_path", "computer_metadata_snapshot_module"),
("data", ""),
])
.send()?;
......@@ -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;
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