Skip to content

Commit

Permalink
Merge pull request #252 from sh-zam/symlink-resolv
Browse files Browse the repository at this point in the history
resolve symlink path
  • Loading branch information
naturallymitchell authored Feb 5, 2019
2 parents 56d4c68 + 961e935 commit d0934a0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use actix_web::{server as actix_server, App};
use rlua::prelude::*;
use std::{
path::{Path, PathBuf},
result
result,
fs
};
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use serde_json::Value;
Expand Down Expand Up @@ -94,7 +95,13 @@ impl AppState {
}

// Lua arg
lua.globals().set("arg", lua.create_sequence_from(self.init_args.clone())?)?;
let mut cmd_args = self.init_args.clone();
// if file path is symlink, then resolve
match fs::read_link(&cmd_args[0]) {
Ok(p) => cmd_args[0] = String::from(p.to_str().unwrap_or("")),
Err(_) => (),
};
lua.globals().set("arg", lua.create_sequence_from(cmd_args)?)?;

// Lua Bridge
lua.exec::<_, ()>(include_str!("handlers/bridge.lua"), None)?;
Expand Down

0 comments on commit d0934a0

Please sign in to comment.