Fix: FileID::from() should also succeed if we pass a ID as string

This commit is contained in:
Matthias Beyer 2015-12-04 22:31:09 +01:00
parent 38158e2edf
commit 253658ece5

View file

@ -127,7 +127,7 @@ impl From<String> for FileID {
impl<'a> From<&'a String> for FileID {
fn from(string: &'a String) -> FileID {
// we assume that it is an path
let regex = Regex::new(r"([:alnum:]*)-([:upper:]*)-([A-Za-z0-9-_]*)\.(.*)").unwrap();
let s = string.split("/").last().unwrap_or("");
@ -160,9 +160,10 @@ impl<'a> From<&'a String> for FileID {
Some(FileID::new(idtype, String::from(hash)))
}).unwrap_or({
debug!("Did not match");
debug!("It is no path, actually. So we assume it is an ID already");
FileID {
id_type: FileIDType::NONE,
id: None,
id: Some(string.clone()),
}
})
}