Add Params::get_file(), ::get_path() and ::get_blob()

Turns out that anyone that uses these either justs wants a file or
wants a blob.  Consolidate those patterns into one place and simplify
all the callers.
This commit is contained in:
Floris Bruynooghe
2019-10-21 22:02:51 +02:00
committed by holger krekel
parent 6c9e16d31a
commit 5d79690260
6 changed files with 137 additions and 103 deletions

View File

@@ -1228,14 +1228,8 @@ unsafe fn create_or_lookup_group(
if part.typ == Viewtype::Image {
grpimage = part
.param
.get(Param::File)
.and_then(|param| ParamsFile::from_param(context, param).ok())
.and_then(|file| match file {
ParamsFile::FsPath(path) => {
BlobObject::create_from_path(context, path).ok()
}
ParamsFile::Blob(blob) => Some(blob),
});
.get_blob(Param::File, context, true)
.unwrap_or(None);
info!(context, "found image {:?}", grpimage);
changed = true;
}