diff --git a/Makefile b/Makefile index 1521676a..7dda68c2 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ SRC_DIR := src SRCS != find '$(SRC_DIR)' -iname '*.v' V_PATH ?= v -V := $(V_PATH) -showcc -gc boehm -W -d use_openssl -skip-unused +V := $(V_PATH) -showcc -gc boehm -d use_openssl -skip-unused all: vieter diff --git a/src/build/queue.v b/src/build/queue.v index 2aa6e7a9..73068ac4 100644 --- a/src/build/queue.v +++ b/src/build/queue.v @@ -143,7 +143,7 @@ pub fn (mut q BuildJobQueue) peek(arch string) ?BuildJob { } q.pop_invalid(arch) - job := q.queues[arch].peek()? + job := q.queues[arch].peek() or { return none } if job.timestamp < time.now() { return job @@ -162,10 +162,10 @@ pub fn (mut q BuildJobQueue) pop(arch string) ?BuildJob { } q.pop_invalid(arch) - mut job := q.queues[arch].peek()? + mut job := q.queues[arch].peek() or { return none } if job.timestamp < time.now() { - job = q.queues[arch].pop()? + job = q.queues[arch].pop() or { return none } if !job.single { q.reschedule(job, arch) diff --git a/src/db/db.v b/src/dbms/dbms.v similarity index 94% rename from src/db/db.v rename to src/dbms/dbms.v index 73a5e83a..686bb522 100644 --- a/src/db/db.v +++ b/src/dbms/dbms.v @@ -1,6 +1,6 @@ -module db +module dbms -import sqlite +import db.sqlite import time pub struct VieterDb { @@ -49,8 +49,8 @@ pub fn init(db_path string) !VieterDb { } // Apply each migration in order - for i in cur_version.version .. db.migrations_up.len { - migration := db.migrations_up[i].to_string() + for i in cur_version.version .. dbms.migrations_up.len { + migration := dbms.migrations_up[i].to_string() version_num := i + 1 diff --git a/src/db/logs.v b/src/dbms/logs.v similarity index 99% rename from src/db/logs.v rename to src/dbms/logs.v index 03211832..b0786b85 100644 --- a/src/db/logs.v +++ b/src/dbms/logs.v @@ -1,4 +1,4 @@ -module db +module dbms import models { BuildLog, BuildLogFilter } import time diff --git a/src/db/migrations/001-initial/down.sql b/src/dbms/migrations/001-initial/down.sql similarity index 100% rename from src/db/migrations/001-initial/down.sql rename to src/dbms/migrations/001-initial/down.sql diff --git a/src/db/migrations/001-initial/up.sql b/src/dbms/migrations/001-initial/up.sql similarity index 100% rename from src/db/migrations/001-initial/up.sql rename to src/dbms/migrations/001-initial/up.sql diff --git a/src/db/migrations/002-rename-to-targets/down.sql b/src/dbms/migrations/002-rename-to-targets/down.sql similarity index 100% rename from src/db/migrations/002-rename-to-targets/down.sql rename to src/dbms/migrations/002-rename-to-targets/down.sql diff --git a/src/db/migrations/002-rename-to-targets/up.sql b/src/dbms/migrations/002-rename-to-targets/up.sql similarity index 100% rename from src/db/migrations/002-rename-to-targets/up.sql rename to src/dbms/migrations/002-rename-to-targets/up.sql diff --git a/src/db/migrations/003-target-url-type/down.sql b/src/dbms/migrations/003-target-url-type/down.sql similarity index 100% rename from src/db/migrations/003-target-url-type/down.sql rename to src/dbms/migrations/003-target-url-type/down.sql diff --git a/src/db/migrations/003-target-url-type/up.sql b/src/dbms/migrations/003-target-url-type/up.sql similarity index 100% rename from src/db/migrations/003-target-url-type/up.sql rename to src/dbms/migrations/003-target-url-type/up.sql diff --git a/src/db/migrations/004-nullable-branch/down.sql b/src/dbms/migrations/004-nullable-branch/down.sql similarity index 100% rename from src/db/migrations/004-nullable-branch/down.sql rename to src/dbms/migrations/004-nullable-branch/down.sql diff --git a/src/db/migrations/004-nullable-branch/up.sql b/src/dbms/migrations/004-nullable-branch/up.sql similarity index 100% rename from src/db/migrations/004-nullable-branch/up.sql rename to src/dbms/migrations/004-nullable-branch/up.sql diff --git a/src/db/migrations/005-repo-path/down.sql b/src/dbms/migrations/005-repo-path/down.sql similarity index 100% rename from src/db/migrations/005-repo-path/down.sql rename to src/dbms/migrations/005-repo-path/down.sql diff --git a/src/db/migrations/005-repo-path/up.sql b/src/dbms/migrations/005-repo-path/up.sql similarity index 100% rename from src/db/migrations/005-repo-path/up.sql rename to src/dbms/migrations/005-repo-path/up.sql diff --git a/src/db/targets.v b/src/dbms/targets.v similarity index 99% rename from src/db/targets.v rename to src/dbms/targets.v index 35ee2706..a55220f9 100644 --- a/src/db/targets.v +++ b/src/dbms/targets.v @@ -1,4 +1,4 @@ -module db +module dbms import models { Target, TargetArch } diff --git a/src/db/targets_iter.v b/src/dbms/targets_iter.v similarity index 99% rename from src/db/targets_iter.v rename to src/dbms/targets_iter.v index 081de1f6..ca149b90 100644 --- a/src/db/targets_iter.v +++ b/src/dbms/targets_iter.v @@ -1,7 +1,7 @@ -module db +module dbms import models { Target, TargetFilter } -import sqlite +import db.sqlite // Iterator providing a filtered view into the list of targets currently stored // in the database. It replaces functionality usually performed in the database diff --git a/src/server/api_logs.v b/src/server/api_logs.v index 3e210b04..00a7e2e2 100644 --- a/src/server/api_logs.v +++ b/src/server/api_logs.v @@ -3,7 +3,6 @@ module server import web import net.urllib import web.response { new_data_response, new_response } -import db import time import os import util diff --git a/src/server/api_targets.v b/src/server/api_targets.v index a8fdf375..ed121d93 100644 --- a/src/server/api_targets.v +++ b/src/server/api_targets.v @@ -2,7 +2,6 @@ module server import web import web.response { new_data_response, new_response } -import db import models { Target, TargetArch, TargetFilter } // v1_get_targets returns the current list of targets. diff --git a/src/server/server.v b/src/server/server.v index 79d93e2c..e1fa0d77 100644 --- a/src/server/server.v +++ b/src/server/server.v @@ -5,7 +5,7 @@ import os import log import repo import util -import db +import dbms import build { BuildJobQueue } import cron import metrics @@ -25,7 +25,7 @@ pub mut: repo repo.RepoGroupManager [required; web_global] // Keys are the various architectures for packages job_queue BuildJobQueue [required; web_global] - db db.VieterDb + db dbms.VieterDb } // init_job_queue populates a fresh job queue with all the targets currently @@ -88,7 +88,7 @@ pub fn server(conf Config) ! { } db_file := os.join_path_single(conf.data_dir, server.db_file_name) - db := db.init(db_file) or { + db := dbms.init(db_file) or { util.exit_with_message(1, 'Failed to initialize database: ${err.msg()}') }