Fix fs_to_write() to serialize headers correctly
This commit is contained in:
parent
c013ca8025
commit
3af1042593
1 changed files with 17 additions and 3 deletions
|
@ -103,10 +103,18 @@ impl Mapper for JsonMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fs_to_write<W: Write>(&self, hm: &mut HashMap<PathBuf, Cursor<Vec<u8>>>, out: &mut W) -> Result<()> {
|
fn fs_to_write<W: Write>(&self, hm: &mut HashMap<PathBuf, Cursor<Vec<u8>>>, out: &mut W) -> Result<()> {
|
||||||
|
use util::entry_buffer_to_header_content;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
struct Entry {
|
||||||
|
header: ::toml::Value,
|
||||||
|
content: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct OutDocument {
|
struct OutDocument {
|
||||||
version: String,
|
version: String,
|
||||||
store: HashMap<PathBuf, String>,
|
store: HashMap<PathBuf, Entry>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut doc = OutDocument {
|
let mut doc = OutDocument {
|
||||||
|
@ -117,8 +125,14 @@ impl Mapper for JsonMapper {
|
||||||
for (key, value) in hm.drain() {
|
for (key, value) in hm.drain() {
|
||||||
let res = String::from_utf8(value.into_inner())
|
let res = String::from_utf8(value.into_inner())
|
||||||
.map_err_into(SEK::IoError)
|
.map_err_into(SEK::IoError)
|
||||||
.map(|entrystr| {
|
.and_then(|buf| entry_buffer_to_header_content(&buf))
|
||||||
doc.store.insert(key, entrystr);
|
.map(|(header, content)| {
|
||||||
|
let entry = Entry {
|
||||||
|
header: header,
|
||||||
|
content: content
|
||||||
|
};
|
||||||
|
|
||||||
|
doc.store.insert(key, entry);
|
||||||
})
|
})
|
||||||
.map(|_| ());
|
.map(|_| ());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue