Merge pull request #10 from ckruse/fix/magic-disabled

compilation fails if magic is disabled because `self.magic` is not available
This commit is contained in:
Scott Boggs 2022-12-27 07:25:11 -05:00 committed by GitHub
commit 40d5277c1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -401,13 +401,14 @@ impl Mastodon {
use std::io::Read;
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
// the filepath if this isn't here and things should still work.
} else {
None
};
// 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.
#[cfg(feature = "magic")]
let mime = self.magic.file(path).ok();
#[cfg(not(feature = "magic"))]
let mime: Option<String> = None;
match std::fs::File::open(path) {
Ok(mut file) => {
let mut data = if let Ok(metadata) = file.metadata() {