Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aknarts committed Apr 14, 2022
1 parent 122c88f commit f07e563
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 32 deletions.
14 changes: 7 additions & 7 deletions src/ui/widgets/download_manager/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,14 +648,14 @@ fn initiate_file_download(
f_name: &str,
sender: &Sender<super::DownloadMsg>,
m: egs_api::api::types::download_manifest::FileManifestList,
full_path: &PathBuf,
full_path: &Path,
) {
if let Ok(w) = crate::RUNNING.read() {
if !*w {
return;
}
};
match File::open(full_path.clone()) {
match File::open(full_path) {
Ok(mut f) => {
let mut buffer: [u8; 1024] = [0; 1024];
let mut hasher = sha1::Sha1::new();
Expand Down Expand Up @@ -810,7 +810,7 @@ impl AssetPriv for super::EpicDownloadManager {
debug!("File finished {}", f.name);
finished_files.push(file.to_string());
let finished = f.clone();
let mut temp = temp_dir.clone();
let mut temp = temp_dir;
temp.push(f.release.clone());
temp.push("temp");
let mut vault = if to_vault || targets.is_empty() {
Expand Down Expand Up @@ -869,12 +869,12 @@ impl AssetPriv for super::EpicDownloadManager {

fn extract_chunks(
chunks: Vec<egs_api::api::types::download_manifest::FileChunkPart>,
temp: &PathBuf,
temp: &Path,
target: &mut File,
) -> CoreWrapper<Sha1Core> {
let mut hasher = Sha1::new();
for chunk in chunks {
let mut t = temp.clone();
let mut t = temp.to_path_buf();
t.push(format!("{}.chunk", chunk.guid));
match File::open(t) {
Ok(mut f) => {
Expand Down Expand Up @@ -905,7 +905,7 @@ fn extract_chunks(
hasher
}

fn copy_files(from: &PathBuf, targets: Vec<(String, bool)>, filename: &str) {
fn copy_files(from: &Path, targets: Vec<(String, bool)>, filename: &str) {
for t in targets {
let mut tar = PathBuf::from_str(&t.0).unwrap();
tar.push(filename);
Expand All @@ -928,7 +928,7 @@ fn copy_files(from: &PathBuf, targets: Vec<(String, bool)>, filename: &str) {
};
}
std::fs::create_dir_all(tar.parent().unwrap()).unwrap();
if let Err(e) = std::fs::copy(from.clone(), tar) {
if let Err(e) = std::fs::copy(from, tar) {
error!("Unable to copy file: {:?}", e);
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/download_manager/download_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub(crate) mod imp {
.get::<Option<String>>()
.expect("type conformity checked by `Object::set_property`");

self.path.replace(path.clone());
self.path.replace(path);
if init {
action!(
self.actions,
Expand Down
23 changes: 9 additions & 14 deletions src/ui/widgets/logged_in/engines/engine_detail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use version_compare::Cmp;

#[derive(Debug, Clone)]
pub enum DockerMsg {
DockerEngineVersions(HashMap<String, Vec<String>>),
DockerError(String),
DockerManifestSize(u64),
EngineVersions(HashMap<String, Vec<String>>),
Error(String),
ManifestSize(u64),
}

pub(crate) mod imp {
Expand Down Expand Up @@ -534,13 +534,13 @@ impl EpicEngineDetails {
pub fn update(&self, msg: DockerMsg) {
let self_ = self.imp();
match msg {
DockerMsg::DockerEngineVersions(ver) => {
DockerMsg::EngineVersions(ver) => {
if let Some(w) = self_.window.get() {
w.clear_notification("ghcr authentication");
}
self.updated_docker_versions(&ver);
}
DockerMsg::DockerManifestSize(size) => {
DockerMsg::ManifestSize(size) => {
let byte = byte_unit::Byte::from_bytes(size as u128).get_appropriate_unit(false);
match self_.settings.strv("unreal-engine-directories").get(0) {
None => {
Expand All @@ -566,7 +566,7 @@ impl EpicEngineDetails {
};
self.set_property("download-size", Some(byte.format(1)));
}
DockerMsg::DockerError(_error) => {
DockerMsg::Error(_error) => {
if let Some(w) = self_.window.get() {
w.add_notification("ghcr authentication", "Unable to authenticate to ghcr please check your setup(did you link with Epic Account?)", gtk4::MessageType::Error);
get_action!(self_.actions, @install).set_enabled(false);
Expand Down Expand Up @@ -601,7 +601,7 @@ impl EpicEngineDetails {
match client.get_manifest("epicgames/unreal-engine", &version) {
Ok(manifest) => match manifest.download_size() {
Ok(size) => {
sender.send(DockerMsg::DockerManifestSize(size)).unwrap();
sender.send(DockerMsg::ManifestSize(size)).unwrap();
}
Err(e) => {
error!("Unable to get manifest size: {:?}", e);
Expand Down Expand Up @@ -653,17 +653,12 @@ impl EpicEngineDetails {
Err(e) => {
error!("Failed to get tags: {:?}", e);
sender
.send(DockerMsg::DockerError(format!(
"Failed to get tags: {:?}",
e
)))
.send(DockerMsg::Error(format!("Failed to get tags: {:?}", e)))
.unwrap();
}
}

sender
.send(DockerMsg::DockerEngineVersions(result))
.unwrap();
sender.send(DockerMsg::EngineVersions(result)).unwrap();
});
} else {
self_.docker_versions.replace(None);
Expand Down
6 changes: 3 additions & 3 deletions src/ui/widgets/logged_in/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ impl EpicEnginesBox {
engines.insert(
guid.clone(),
UnrealEngine {
version: version.clone(),
path: path.clone(),
guid: Some(guid.clone()),
version,
path,
guid: Some(guid),
},
);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/logged_in/library/create_asset_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl EpicCreateAssetProject {
}
),
);
if let None = self_.select_target_directory.active_text() {
if self_.select_target_directory.active_text().is_none() {
self_.select_target_directory.set_active_id(Some(&dir));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/logged_in/library/download_detail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl EpicDownloadDetails {
}
),
);
if let None = self_.select_target_directory.active_text() {
if self_.select_target_directory.active_text().is_none() {
self_.select_target_directory.set_active_id(Some(&dir));
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/ui/widgets/logged_in/library/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ impl EpicLibraryBox {
.chars()
.filter(|c| c.is_ascii_alphanumeric() || c.is_ascii_whitespace())
.collect();
let title: String = title.to_lowercase().replace(" ", "-");
let title: String = title.to_lowercase().replace(' ', "-");
asset_products.insert(title, asset.id.clone());
}
true
Expand All @@ -799,7 +799,7 @@ impl EpicLibraryBox {
.chars()
.filter(|c| c.is_ascii_alphanumeric() || c.is_ascii_whitespace())
.collect();
let title: String = title.to_lowercase().replace(" ", "-");
let title: String = title.to_lowercase().replace(' ', "-");
asset_products.insert(title, asset.id.clone());
}
true
Expand Down Expand Up @@ -833,7 +833,7 @@ impl EpicLibraryBox {
.set_fraction(f64::from(self.loaded()) / f64::from(self.loading()));
self_
.refresh_progress
.set_visible(!(self.loaded() == self.loading()));
.set_visible(self.loaded() != self.loading());
}

fn add_category(&self, path: &str) {
Expand Down
5 changes: 3 additions & 2 deletions src/ui/widgets/logged_in/projects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,16 @@ impl EpicProjectsBox {
}
}

fn add_project(&self, uproject_file: &PathBuf) {
fn add_project(&self, uproject_file: &Path) {
let self_ = self.imp();
if let Some(directory) = uproject_file.parent() {
if let Some(oname) = uproject_file.file_stem() {
if let Some(name) = oname.to_str() {
if let None = self_
if self_
.projects
.borrow_mut()
.insert(directory.to_str().unwrap().to_string(), name.to_string())
.is_none()
{
self_
.grid_model
Expand Down

0 comments on commit f07e563

Please sign in to comment.