Remove web dependency on VfsSession and friends, use Instant for timing instead

This commit is contained in:
Lucien Greathouse 2018-04-05 13:13:04 -07:00
parent 20ccb2b0c4
commit 1d84c8013e
2 changed files with 6 additions and 7 deletions

View file

@ -1,6 +1,6 @@
use std::path::{Path, PathBuf};
use std::process;
use std::sync::{Arc, Mutex};
use std::time::Instant;
use rand;
@ -87,5 +87,5 @@ pub fn serve(project_path: &PathBuf, verbose: bool, port: Option<u64>) {
println!("Server listening on port {}", web_config.port);
web::start(web_config, project.clone(), &PLUGIN_CHAIN, vfs.clone());
web::start(web_config, project.clone(), Instant::now());
}

View file

@ -1,10 +1,9 @@
use std::sync::{Arc, Mutex};
use std::time::Instant;
use rouille;
use project::Project;
use vfs::{VfsSession};
use middleware::MiddlewareChain;
use web_util::json;
/// The set of configuration the web server needs to start.
@ -25,7 +24,7 @@ struct ServerInfo<'a> {
}
/// Start the Rojo web server and park our current thread.
pub fn start(config: WebConfig, project: Project, _middleware_chain: &'static MiddlewareChain, vfs: Arc<Mutex<VfsSession>>) {
pub fn start(config: WebConfig, project: Project, start_time: Instant) {
let address = format!("localhost:{}", config.port);
let server_id = config.server_id.to_string();
@ -36,9 +35,9 @@ pub fn start(config: WebConfig, project: Project, _middleware_chain: &'static Mi
// Get a summary of information about the server.
let current_time = {
let vfs = vfs.lock().unwrap();
let elapsed = start_time.elapsed();
vfs.current_time()
elapsed.as_secs() as f64 + elapsed.subsec_nanos() as f64 / 1_000_000_000.0
};
json(ServerInfo {