Convert BlobError into an enum

This deletes a lot of code and complexity.  Though comes at some cost:

- The type no longer fits in a register and will always be on the
  stack.

- Constructing the errors is more verbose, no more auto Into casting.
This commit is contained in:
Floris Bruynooghe
2019-11-30 02:57:26 +01:00
committed by Floris Bruynooghe
parent 084a87ed61
commit 74a4691f29
3 changed files with 86 additions and 186 deletions

View File

@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
use itertools::Itertools;
use num_traits::FromPrimitive;
use crate::blob::{BlobErrorKind, BlobObject};
use crate::blob::{BlobError, BlobObject};
use crate::chatlist::*;
use crate::config::*;
use crate::constants::*;
@@ -1797,8 +1797,8 @@ pub fn set_chat_profile_image(
));
} else {
let image_blob = BlobObject::from_path(context, Path::new(new_image.as_ref())).or_else(
|err| match err.kind() {
BlobErrorKind::WrongBlobdir => {
|err| match err {
BlobError::WrongBlobdir { .. } => {
BlobObject::create_and_copy(context, Path::new(new_image.as_ref()))
}
_ => Err(err),