update
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
JMARyA 2024-12-27 04:28:05 +01:00
parent fcd3d6ffca
commit ac07105bf7
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
6 changed files with 87 additions and 29 deletions

View file

@ -4,6 +4,26 @@ pub struct Repository {
pub name: String,
}
impl Repository {
pub fn list() -> Vec<String> {
let mut repos = vec![];
for entry in std::fs::read_dir("./data").unwrap() {
let path = entry.unwrap().path();
let file_name = path.file_name().unwrap().to_str().unwrap().to_string();
repos.push(file_name);
}
repos
}
pub fn create(name: &str) -> Repository {
let path = PathBuf::from("./data").join(name);
std::fs::create_dir_all(path).unwrap();
Repository::new(name).unwrap()
}
}
impl Repository {
pub fn new(name: &str) -> Option<Self> {
if PathBuf::from("./data").join(name).exists() {