Skip to content

Commit

Permalink
ensure pathes are relative to cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkootter committed Dec 23, 2021
1 parent ad3125a commit d6652b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ jobs:
- uses: actions/upload-artifact@v2
with:
name: linux-binary
path: deploy
5 changes: 5 additions & 0 deletions src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ impl SignedFile {
}

pub fn deploy(&self) -> Result<(), ()> {
let current_dir = std::env::current_dir().or(Err(()))?;

use std::io::Write;

let path = std::path::Path::new(&self.filename);
let path = path.canonicalize().or(Err(()))?;
let path = path.strip_prefix(current_dir).or(Err(()))?;

let mut f = std::fs::File::create(path).or(Err(()))?;
f.write_all(&self.file).or(Err(()))?;
Ok(())
Expand Down

0 comments on commit d6652b3

Please sign in to comment.