mirror of
https://github.com/amigan/rustypaste-pretty.git
synced 2024-11-21 20:09:48 -05:00
feat(paste): guess the extension if it is not present
This commit is contained in:
parent
12c204bf03
commit
ef57b48868
3 changed files with 16 additions and 1 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -926,6 +926,12 @@ dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "infer"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ea70330449622910e0edebab230734569516269fb32342fb0a8956340fa48c6c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "instant"
|
name = "instant"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
|
@ -1241,6 +1247,7 @@ dependencies = [
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
"infer",
|
||||||
"log",
|
"log",
|
||||||
"petname",
|
"petname",
|
||||||
"rand 0.8.4",
|
"rand 0.8.4",
|
||||||
|
|
|
@ -22,6 +22,10 @@ dotenv = "0.15.0"
|
||||||
version = "4.0.12"
|
version = "4.0.12"
|
||||||
features = ["serde"]
|
features = ["serde"]
|
||||||
|
|
||||||
|
[dependencies.infer]
|
||||||
|
version = "0.5.0"
|
||||||
|
default-features = false
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "2.2.0"
|
actix-rt = "2.2.0"
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,11 @@ pub fn save(mut file_name: &str, bytes: &[u8], config: &Config) -> IoResult<Stri
|
||||||
.collect::<String>(),
|
.collect::<String>(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
path.set_extension(&config.paste.default_extension);
|
path.set_extension(
|
||||||
|
infer::get(bytes)
|
||||||
|
.map(|t| t.extension())
|
||||||
|
.unwrap_or(&config.paste.default_extension),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut buffer = File::create(&path)?;
|
let mut buffer = File::create(&path)?;
|
||||||
|
|
Loading…
Reference in a new issue