})
}
- pub fn create_image_writer<P: AsRef<Path>>(&mut self, filename: P, size: usize) -> Result<ImageIndexWriter, Error> {
+ pub fn create_image_writer<P: AsRef<Path>>(&mut self, filename: P, size: usize, chunk_size: usize) -> Result<ImageIndexWriter, Error> {
- let index = ImageIndexWriter::create(&mut self.chunk_store, filename.as_ref(), size)?;
+ let index = ImageIndexWriter::create(&mut self.chunk_store, filename.as_ref(), size, chunk_size)?;
Ok(index)
}
impl <'a> ImageIndexWriter<'a> {
- pub fn create(store: &'a mut ChunkStore, path: &Path, size: usize) -> Result<Self, Error> {
+ pub fn create(store: &'a mut ChunkStore, path: &Path, size: usize, chunk_size: usize) -> Result<Self, Error> {
let full_path = store.relative_path(path);
let mut tmp_path = full_path.clone();
.write(true)
.open(&tmp_path)?;
- let chunk_size = 64*1024; // fixed size for now??
-
let header_size = std::mem::size_of::<ImageIndexHeader>();
// todo: use static assertion when available in rust
if stat.st_size <= 0 { bail!("got strange file size '{}'", stat.st_size); }
let size = stat.st_size as usize;
- let mut index = datastore.create_image_writer(&target, size)?;
+ let chunk_size = 1024*1024;
- tools::file_chunker(file, 64*1024, |pos, chunk| {
+ let mut index = datastore.create_image_writer(&target, size, chunk_size)?;
+
+ tools::file_chunker(file, chunk_size, |pos, chunk| {
index.add_chunk(pos, chunk)?;
Ok(true)
})?;