if magic is disabled `self.magic` is not available
and thus compilation fails with `if cfg!()` construct
This commit is contained in:
parent
b571352dca
commit
e0ba85ea1b
|
@ -401,13 +401,14 @@ impl Mastodon {
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
let mime = if cfg!(feature = "magic") {
|
|
||||||
self.magic.file(path).ok()
|
|
||||||
// if it doesn't work, it's no big deal. The server will look at
|
// if it doesn't work, it's no big deal. The server will look at
|
||||||
// the filepath if this isn't here and things should still work.
|
// the filepath if this isn't here and things should still work.
|
||||||
} else {
|
#[cfg(feature = "magic")]
|
||||||
None
|
let mime = self.magic.file(path).ok();
|
||||||
};
|
#[cfg(not(feature = "magic"))]
|
||||||
|
let mime: Option<String> = None;
|
||||||
|
|
||||||
match std::fs::File::open(path) {
|
match std::fs::File::open(path) {
|
||||||
Ok(mut file) => {
|
Ok(mut file) => {
|
||||||
let mut data = if let Ok(metadata) = file.metadata() {
|
let mut data = if let Ok(metadata) = file.metadata() {
|
||||||
|
|
Loading…
Reference in New Issue