From f498ffa54c5922d22bc4dc702a3ec09c55cbe00b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 24 Nov 2015 10:27:42 +0100 Subject: [PATCH] Implement Storage::put_file() --- src/storage/backend.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/storage/backend.rs b/src/storage/backend.rs index d67f1e41..b83e4366 100644 --- a/src/storage/backend.rs +++ b/src/storage/backend.rs @@ -13,6 +13,7 @@ use glob::Paths; use storage::file::File; use storage::file_id::*; +use storage::parser::{FileHeaderParser, Parser, ParserError}; use module::Module; use runtime::Runtime; @@ -60,7 +61,18 @@ impl StorageBackend { * * The file is moved to this function as the file won't be edited afterwards */ - pub fn put_file(f: File) -> BackendOperationResult { + pub fn put_file<'a, HP>(&self, f: File, p: &Parser) -> + Result + where HP: FileHeaderParser<'a> + { + let written = p.write(f.contents()); + if let Ok(string) = written { + let path = self.basepath + &f.id()[..]; + debug!("Writing file: {}", path); + Ok(Ok(())) + } else { + Err(written.err().unwrap()) + } } /*