~/selfhut

selfhut/src/clone.rs -rw-r--r-- 381 B
00c0a257 — Arthur Melton format code 2 years ago

            
7dbdfabf arthurmelton
00c0a257 Arthur Melton
616316d3 Arthur Melton
00c0a257 Arthur Melton
7dbdfabf arthurmelton
7dbdfabf arthurmelton





1
2
3
4
5
6
7
8
9
10
11
use crate::config::CONFIG;
use crate::PathBufWithDotfiles;
use rocket::fs::NamedFile;

#[get("/<repo>/<path..>", rank = 3)]
pub async fn clone(repo: String, path: PathBufWithDotfiles) -> Option<NamedFile> {
    let mut repo_path = CONFIG.git_location.clone();
    repo_path.push(format!("{}.git", repo));
    repo_path.push(path.get());
    NamedFile::open(repo_path).await.ok()
}