Working drag and drop
This commit is contained in:
@@ -298,33 +298,23 @@ pub async fn install_paths(
|
|||||||
let file = Path::new(&path)
|
let file = Path::new(&path)
|
||||||
.file_name()
|
.file_name()
|
||||||
.and_then(|name| name.to_str())
|
.and_then(|name| name.to_str())
|
||||||
.unwrap_or_default();
|
.ok_or_else(|| String::from("File name not found"))?;
|
||||||
|
|
||||||
if file.is_empty() {
|
|
||||||
println!("Error: Unable to obtain file");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let version_dir = LAUNCHER_DIR.data_dir().join(&state.lock().unwrap().version);
|
let version_dir = LAUNCHER_DIR.data_dir().join(&state.lock().unwrap().version);
|
||||||
|
|
||||||
let mc_child = if path.ends_with(".jar") {
|
let mc_child = if path.ends_with(".jar") {
|
||||||
Some("mods")
|
"mods"
|
||||||
} else {
|
} else {
|
||||||
None
|
return Err(String::from("Invalid file type"));
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(mc_child) = mc_child {
|
fs::copy(path, version_dir.join(mc_child).join(file))
|
||||||
match fs::copy(path, version_dir.join(mc_child).join(file)).await {
|
.await
|
||||||
Ok(_) => {
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
app.emit("path-installed", path.to_string())
|
app.emit("path-installed", path.to_string())
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
|
||||||
println!("Error: failed to copy mod {file:?}: {e}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -82,7 +82,7 @@ export default function App() {
|
|||||||
toast.promise(installPaths(version, [path]), {
|
toast.promise(installPaths(version, [path]), {
|
||||||
loading: `${fileName}`,
|
loading: `${fileName}`,
|
||||||
success: `${fileName}`,
|
success: `${fileName}`,
|
||||||
error: `${fileName} Failed`
|
error: (e) => `${fileName} Failed: ${e}`
|
||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user