Renamed data_dir to repos_dir

main^2
Jef Roosens 2022-04-07 15:21:27 +02:00
parent a5ac0b6956
commit 3b555efa91
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
7 changed files with 14 additions and 14 deletions

View File

@ -31,7 +31,7 @@ RUN if [ -n "${CI_COMMIT_SHA}" ]; then \
FROM busybox:1.35.0 FROM busybox:1.35.0
ENV PATH=/bin \ ENV PATH=/bin \
VIETER_REPO_DIR=/data/repo \ VIETER_REPOS_DIR=/data/repos \
VIETER_PKG_DIR=/data/pkgs \ VIETER_PKG_DIR=/data/pkgs \
VIETER_DOWNLOAD_DIR=/data/downloads \ VIETER_DOWNLOAD_DIR=/data/downloads \
VIETER_REPOS_FILE=/data/repos.json VIETER_REPOS_FILE=/data/repos.json

View File

@ -11,7 +11,7 @@ mut:
mutex shared util.Dummy mutex shared util.Dummy
pub: pub:
// Where to store repositories' files // Where to store repositories' files
data_dir string [required] repos_dir string [required]
// Where packages are stored; each architecture gets its own subdirectory // Where packages are stored; each architecture gets its own subdirectory
pkg_dir string [required] pkg_dir string [required]
// The default architecture to use for a repository. In reality, this value // The default architecture to use for a repository. In reality, this value
@ -27,9 +27,9 @@ pub:
} }
// new creates a new RepoGroupManager & creates the directories as needed // new creates a new RepoGroupManager & creates the directories as needed
pub fn new(data_dir string, pkg_dir string, default_arch string) ?RepoGroupManager { pub fn new(repos_dir string, pkg_dir string, default_arch string) ?RepoGroupManager {
if !os.is_dir(data_dir) { if !os.is_dir(repos_dir) {
os.mkdir_all(data_dir) or { return error('Failed to create repo directory: $err.msg') } os.mkdir_all(repos_dir) or { return error('Failed to create repos directory: $err.msg') }
} }
if !os.is_dir(pkg_dir) { if !os.is_dir(pkg_dir) {
@ -37,7 +37,7 @@ pub fn new(data_dir string, pkg_dir string, default_arch string) ?RepoGroupManag
} }
return RepoGroupManager{ return RepoGroupManager{
data_dir: data_dir repos_dir: repos_dir
pkg_dir: pkg_dir pkg_dir: pkg_dir
default_arch: default_arch default_arch: default_arch
} }
@ -83,7 +83,7 @@ fn (r &RepoGroupManager) add_pkg_in_repo(repo string, pkg &package.Pkg) ?bool {
return r.add_pkg_in_arch_repo(repo, pkg.info.arch, pkg) return r.add_pkg_in_arch_repo(repo, pkg.info.arch, pkg)
} }
repo_dir := os.join_path_single(r.data_dir, repo) repo_dir := os.join_path_single(r.repos_dir, repo)
mut arch_repos := []string{} mut arch_repos := []string{}
@ -118,7 +118,7 @@ fn (r &RepoGroupManager) add_pkg_in_repo(repo string, pkg &package.Pkg) ?bool {
// changes. The function returns false if the package was already present in // changes. The function returns false if the package was already present in
// the repo, and true otherwise. // the repo, and true otherwise.
fn (r &RepoGroupManager) add_pkg_in_arch_repo(repo string, arch string, pkg &package.Pkg) ?bool { fn (r &RepoGroupManager) add_pkg_in_arch_repo(repo string, arch string, pkg &package.Pkg) ?bool {
pkg_dir := os.join_path(r.data_dir, repo, arch, '$pkg.info.name-$pkg.info.version') pkg_dir := os.join_path(r.repos_dir, repo, arch, '$pkg.info.name-$pkg.info.version')
// We can't add the same package twice // We can't add the same package twice
if os.exists(pkg_dir) { if os.exists(pkg_dir) {
@ -150,7 +150,7 @@ fn (r &RepoGroupManager) add_pkg_in_arch_repo(repo string, arch string, pkg &pac
// returns false if the package wasn't present in the database. It also // returns false if the package wasn't present in the database. It also
// optionally re-syncs the repo archives. // optionally re-syncs the repo archives.
fn (r &RepoGroupManager) remove_pkg_from_arch_repo(repo string, arch string, pkg &package.Pkg, sync bool) ?bool { fn (r &RepoGroupManager) remove_pkg_from_arch_repo(repo string, arch string, pkg &package.Pkg, sync bool) ?bool {
repo_dir := os.join_path(r.data_dir, repo, arch) repo_dir := os.join_path(r.repos_dir, repo, arch)
// If the repository doesn't exist yet, the result is automatically false // If the repository doesn't exist yet, the result is automatically false
if !os.exists(repo_dir) { if !os.exists(repo_dir) {

View File

@ -31,7 +31,7 @@ fn archive_add_entry(archive &C.archive, entry &C.archive_entry, file_path &stri
// Re-generate the repo archive files // Re-generate the repo archive files
fn (r &RepoGroupManager) sync(repo string, arch string) ? { fn (r &RepoGroupManager) sync(repo string, arch string) ? {
subrepo_path := os.join_path(r.data_dir, repo, arch) subrepo_path := os.join_path(r.repos_dir, repo, arch)
lock r.mutex { lock r.mutex {
a_db := C.archive_write_new() a_db := C.archive_write_new()

View File

@ -10,7 +10,7 @@ pub:
pkg_dir string pkg_dir string
download_dir string download_dir string
api_key string api_key string
data_dir string repos_dir string
repos_file string repos_file string
default_arch string default_arch string
} }

View File

@ -23,7 +23,7 @@ fn (mut app App) get_repo_file(repo string, arch string, filename string) web.Re
db_exts := ['.db', '.files', '.db.tar.gz', '.files.tar.gz'] db_exts := ['.db', '.files', '.db.tar.gz', '.files.tar.gz']
if db_exts.any(filename.ends_with(it)) { if db_exts.any(filename.ends_with(it)) {
full_path = os.join_path(app.repo.data_dir, repo, arch, filename) full_path = os.join_path(app.repo.repos_dir, repo, arch, filename)
// repo-add does this using symlinks, but we just change the requested // repo-add does this using symlinks, but we just change the requested
// path // path

View File

@ -44,7 +44,7 @@ pub fn server(conf Config) ? {
} }
// This also creates the directories if needed // This also creates the directories if needed
repo := repo.new(conf.data_dir, conf.pkg_dir, conf.default_arch) or { repo := repo.new(conf.repos_dir, conf.pkg_dir, conf.default_arch) or {
logger.error(err.msg) logger.error(err.msg)
exit(1) exit(1)
} }

View File

@ -1,7 +1,7 @@
# This file contains settings used during development # This file contains settings used during development
api_key = "test" api_key = "test"
download_dir = "data/downloads" download_dir = "data/downloads"
data_dir = "data" repos_dir = "data/repos"
pkg_dir = "data/pkgs" pkg_dir = "data/pkgs"
log_level = "DEBUG" log_level = "DEBUG"
repos_file = "data/repos.json" repos_file = "data/repos.json"