Explorer public folder being relative to the binary (#447)
* Explorer public folder being relative to the binary * Qualifying the public mounting path Co-authored-by: Dave <futurechimp@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c18766a617
commit
830a89cfd4
@@ -7,6 +7,15 @@ pub async fn renew_periodically(validator_base_url: &str) -> Result<(), Error> {
|
||||
let url = format!("{}/{}", validator_base_url, RELATIVE_PATH);
|
||||
|
||||
let topology_json = reqwest::get(&url).await?.text().await?;
|
||||
file::save(topology_json, "public/downloads/mixmining.json");
|
||||
|
||||
let save_path = std::env::current_exe()
|
||||
.expect("Failed to evaluate current exe path")
|
||||
.parent()
|
||||
.expect("the binary itself has no parent path?!")
|
||||
.join("public")
|
||||
.join("downloads")
|
||||
.join("mixmining.json");
|
||||
|
||||
file::save(topology_json, save_path);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -7,6 +7,15 @@ pub async fn renew_periodically(validator_base_url: &str) -> Result<(), Error> {
|
||||
let url = format!("{}/{}", validator_base_url, RELATIVE_PATH);
|
||||
|
||||
let topology_json = reqwest::get(&url).await?.text().await?;
|
||||
file::save(topology_json, "public/downloads/topology.json");
|
||||
|
||||
let save_path = std::env::current_exe()
|
||||
.expect("Failed to evaluate current exe path")
|
||||
.parent()
|
||||
.expect("the binary itself has no parent path?!")
|
||||
.join("public")
|
||||
.join("downloads")
|
||||
.join("topology.json");
|
||||
|
||||
file::save(topology_json, save_path);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -37,9 +37,15 @@ async fn main() {
|
||||
let matches = parse_args();
|
||||
let validator_base_url = matches.value_of(VALIDATOR_ARG).unwrap();
|
||||
|
||||
let public_path = std::env::current_exe()
|
||||
.expect("Failed to evaluate current exe path")
|
||||
.parent()
|
||||
.expect("the binary itself has no parent path?!")
|
||||
.join("public");
|
||||
|
||||
tokio::task::spawn_blocking(|| {
|
||||
rocket::ignite()
|
||||
.mount("/", StaticFiles::from("public"))
|
||||
.mount("/", StaticFiles::from(public_path))
|
||||
.launch()
|
||||
});
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use std::{fs::File, io::Write, path::Path};
|
||||
|
||||
pub fn save(text: String, path_str: &str) {
|
||||
let path = Path::new(path_str);
|
||||
pub fn save<P: AsRef<Path>>(text: String, path: P) {
|
||||
let path = path.as_ref();
|
||||
let display = path.display();
|
||||
|
||||
let mut file = match File::create(&path) {
|
||||
let mut file = match File::create(path) {
|
||||
Err(why) => panic!("couldn't open {}: {}", display, why),
|
||||
Ok(file) => file,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user