mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
let BlobObject::new_from_path() also accept , this allows to use the function for values from the database and from outside, which is handy in situations where you do not really know
This commit is contained in:
@@ -168,6 +168,9 @@ impl<'a> BlobObject<'a> {
|
|||||||
/// subdirectory is used and [BlobObject::sanitise_name] does not
|
/// subdirectory is used and [BlobObject::sanitise_name] does not
|
||||||
/// modify the filename.
|
/// modify the filename.
|
||||||
///
|
///
|
||||||
|
/// Paths into the blob directory may be either defined by an absolute path
|
||||||
|
/// or by the relative prefix `$BLOBDIR`.
|
||||||
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// This merely delegates to the [BlobObject::create_and_copy] and
|
/// This merely delegates to the [BlobObject::create_and_copy] and
|
||||||
@@ -179,6 +182,11 @@ impl<'a> BlobObject<'a> {
|
|||||||
) -> std::result::Result<BlobObject<'_>, BlobError> {
|
) -> std::result::Result<BlobObject<'_>, BlobError> {
|
||||||
if src.as_ref().starts_with(context.get_blobdir()) {
|
if src.as_ref().starts_with(context.get_blobdir()) {
|
||||||
BlobObject::from_path(context, src)
|
BlobObject::from_path(context, src)
|
||||||
|
} else if src.as_ref().starts_with("$BLOBDIR/") {
|
||||||
|
BlobObject::from_name(
|
||||||
|
context,
|
||||||
|
src.as_ref().to_str().unwrap_or_default().to_string(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
BlobObject::create_and_copy(context, src).await
|
BlobObject::create_and_copy(context, src).await
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user