Very alpha support for multiple & multi-arch repos

This commit is contained in:
Jef Roosens 2022-03-27 16:33:06 +02:00
parent 013ce511d7
commit a47cace296
Signed by untrusted user: Jef Roosens
GPG key ID: B75D4F293C7052DB
8 changed files with 83 additions and 47 deletions

View file

@ -8,6 +8,8 @@ import rand
import util
import net.http
const default_repo = "vieter"
// healthcheck just returns a string, but can be used to quickly check if the
// server is still responsive.
['/health'; get]
@ -21,9 +23,9 @@ fn (mut app App) get_root(filename string) web.Result {
mut full_path := ''
if filename.ends_with('.db') || filename.ends_with('.files') {
full_path = os.join_path_single(app.repo.repo_dir, '${filename}.tar.gz')
full_path = os.join_path_single(app.repo.data_dir, '${filename}.tar.gz')
} else if filename.ends_with('.db.tar.gz') || filename.ends_with('.files.tar.gz') {
full_path = os.join_path_single(app.repo.repo_dir, '$filename')
full_path = os.join_path_single(app.repo.data_dir, '$filename')
} else {
full_path = os.join_path_single(app.repo.pkg_dir, filename)
}
@ -74,7 +76,7 @@ fn (mut app App) put_package() web.Result {
return app.text("Content-Type header isn't set.")
}
res := app.repo.add_from_path(pkg_path) or {
res := app.repo.add_pkg_from_path(default_repo, pkg_path) or {
app.lerror('Error while adding package: $err.msg')
os.rm(pkg_path) or { app.lerror("Failed to remove download '$pkg_path': $err.msg") }

View file

@ -14,7 +14,7 @@ struct App {
pub:
conf env.ServerConfig [required; web_global]
pub mut:
repo repo.Repo [required; web_global]
repo repo.RepoGroupManager [required; web_global]
// This is used to claim the file lock on the repos file
git_mutex shared util.Dummy
}
@ -42,7 +42,7 @@ pub fn server() ? {
}
// This also creates the directories if needed
repo := repo.new(conf.repo_dir, conf.pkg_dir) or {
repo := repo.new(conf.data_dir, conf.pkg_dir, "x86_64") or {
logger.error(err.msg)
exit(1)
}