optimize file opening

This commit is contained in:
Edward Shen 2021-05-20 14:23:16 -04:00
parent ea8e031a3d
commit 7acc126de2
Signed by: edward
GPG key ID: 19182661E818369F

3
src/cache/fs.rs vendored
View file

@ -78,8 +78,7 @@ static WRITING_STATUS: Lazy<RwLock<HashMap<PathBuf, Receiver<WritingStatus>>>> =
pub(super) async fn read_file( pub(super) async fn read_file(
path: &Path, path: &Path,
) -> Option<Result<(InnerStream, Option<Header>, ImageMetadata), std::io::Error>> { ) -> Option<Result<(InnerStream, Option<Header>, ImageMetadata), std::io::Error>> {
let std_file = std::fs::File::open(path).ok()?; let mut file = File::open(path).await.ok()?;
let mut file = File::from_std(std_file.try_clone().ok()?);
let mut reader = { let mut reader = {
// If the encryption key was set, use the encrypted disk reader instead; // If the encryption key was set, use the encrypted disk reader instead;