serialize json human readable, save before serializing

This commit is contained in:
əlemi 2022-03-27 13:16:32 +02:00
parent c085d9183e
commit 2e0d035b2f
No known key found for this signature in database
GPG key ID: F239DD0985A7A5E9

View file

@ -53,7 +53,7 @@ impl JsonStorage {
pub fn save(&self) -> Result<(), std::io::Error> {
let mut f = std::fs::File::create(&self.path)?;
f.write(serde_json::to_string(&self.data)?.as_bytes())?;
f.write(serde_json::to_string_pretty(&self.data)?.as_bytes())?;
Ok(())
}
}
@ -167,6 +167,7 @@ impl MemoStorage for JsonStorage {
impl RemoteSync for JsonStorage {
fn serialize(&self) -> Result<Vec<u8>, MemoError> {
self.save()?;
return Ok(std::fs::read(&self.path).unwrap());
}