mirror of
https://git.alemi.dev/memo-cli.git
synced 2024-11-14 05:49:19 +01:00
serialize json human readable, save before serializing
This commit is contained in:
parent
c085d9183e
commit
2e0d035b2f
1 changed files with 2 additions and 1 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue