use .keys() and remove unneccery .to_vec()

This commit is contained in:
hamidreza kalbasi 2021-06-08 17:05:13 +04:30 committed by Timo Kösters
parent 804105479c
commit ff841b73c5
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
2 changed files with 4 additions and 4 deletions

View File

@ -16,7 +16,7 @@ pub mod users;
use crate::{utils, Error, Result}; use crate::{utils, Error, Result};
use abstraction::DatabaseEngine; use abstraction::DatabaseEngine;
use directories::ProjectDirs; use directories::ProjectDirs;
use log::{error, info}; use log::error;
use rocket::futures::{channel::mpsc, stream::FuturesUnordered, StreamExt}; use rocket::futures::{channel::mpsc, stream::FuturesUnordered, StreamExt};
use ruma::{DeviceId, ServerName, UserId}; use ruma::{DeviceId, ServerName, UserId};
use serde::Deserialize; use serde::Deserialize;

View File

@ -108,7 +108,7 @@ impl Media {
let mut iter = self.mediaid_file.scan_prefix(prefix); let mut iter = self.mediaid_file.scan_prefix(prefix);
if let Some((key, _)) = iter.next() { if let Some((key, _)) = iter.next() {
let path = globals.get_media_file(&key.to_vec()); let path = globals.get_media_file(&key);
let mut file = vec![]; let mut file = vec![];
File::open(path).await?.read_to_end(&mut file).await?; File::open(path).await?.read_to_end(&mut file).await?;
let mut parts = key.rsplit(|&b| b == 0xff); let mut parts = key.rsplit(|&b| b == 0xff);
@ -197,7 +197,7 @@ impl Media {
if let Some((key, _)) = self.mediaid_file.scan_prefix(thumbnail_prefix).next() { if let Some((key, _)) = self.mediaid_file.scan_prefix(thumbnail_prefix).next() {
// Using saved thumbnail // Using saved thumbnail
let path = globals.get_media_file(&key.to_vec()); let path = globals.get_media_file(&key);
let mut file = vec![]; let mut file = vec![];
File::open(path).await?.read_to_end(&mut file).await?; File::open(path).await?.read_to_end(&mut file).await?;
let mut parts = key.rsplit(|&b| b == 0xff); let mut parts = key.rsplit(|&b| b == 0xff);
@ -232,7 +232,7 @@ impl Media {
})) }))
} else if let Some((key, _)) = self.mediaid_file.scan_prefix(original_prefix).next() { } else if let Some((key, _)) = self.mediaid_file.scan_prefix(original_prefix).next() {
// Generate a thumbnail // Generate a thumbnail
let path = globals.get_media_file(&key.to_vec()); let path = globals.get_media_file(&key);
let mut file = vec![]; let mut file = vec![];
File::open(path).await?.read_to_end(&mut file).await?; File::open(path).await?.read_to_end(&mut file).await?;