ciruela 0.6.12

A peer-to-peer synchronization software for servers in datacenters.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::io::{Write};

use index::{ImageId};
use metadata::{Meta, Error};


pub fn write(id: &ImageId, data: Vec<u8>, meta: &Meta)
    -> Result<(), Error>
{
    // TODO(tailhook) assert on thread name
    let hex_id = id.to_string();
    let filename = format!("{}.ds1", &hex_id);
    let base = meta.indexes()?.ensure_dir(&hex_id[..2])?;
    base.replace_file(&filename, |mut f| f.write_all(&data))?;
    Ok(())
}