From 91a976c63425559508688c8ffbf05c268dd070e6 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Wed, 8 Feb 2023 11:09:18 +0100 Subject: [PATCH] chore: rename db module to avoid conflict with vlib --- Makefile | 2 +- src/build/queue.v | 6 +++--- src/{db/db.v => dbms/dbms.v} | 8 ++++---- src/{db => dbms}/logs.v | 2 +- src/{db => dbms}/migrations/001-initial/down.sql | 0 src/{db => dbms}/migrations/001-initial/up.sql | 0 .../migrations/002-rename-to-targets/down.sql | 0 src/{db => dbms}/migrations/002-rename-to-targets/up.sql | 0 src/{db => dbms}/migrations/003-target-url-type/down.sql | 0 src/{db => dbms}/migrations/003-target-url-type/up.sql | 0 src/{db => dbms}/migrations/004-nullable-branch/down.sql | 0 src/{db => dbms}/migrations/004-nullable-branch/up.sql | 0 src/{db => dbms}/migrations/005-repo-path/down.sql | 0 src/{db => dbms}/migrations/005-repo-path/up.sql | 0 src/{db => dbms}/targets.v | 2 +- src/{db => dbms}/targets_iter.v | 4 ++-- src/server/api_logs.v | 1 - src/server/api_targets.v | 1 - src/server/server.v | 6 +++--- 19 files changed, 15 insertions(+), 17 deletions(-) rename src/{db/db.v => dbms/dbms.v} (94%) rename src/{db => dbms}/logs.v (99%) rename src/{db => dbms}/migrations/001-initial/down.sql (100%) rename src/{db => dbms}/migrations/001-initial/up.sql (100%) rename src/{db => dbms}/migrations/002-rename-to-targets/down.sql (100%) rename src/{db => dbms}/migrations/002-rename-to-targets/up.sql (100%) rename src/{db => dbms}/migrations/003-target-url-type/down.sql (100%) rename src/{db => dbms}/migrations/003-target-url-type/up.sql (100%) rename src/{db => dbms}/migrations/004-nullable-branch/down.sql (100%) rename src/{db => dbms}/migrations/004-nullable-branch/up.sql (100%) rename src/{db => dbms}/migrations/005-repo-path/down.sql (100%) rename src/{db => dbms}/migrations/005-repo-path/up.sql (100%) rename src/{db => dbms}/targets.v (99%) rename src/{db => dbms}/targets_iter.v (99%) diff --git a/Makefile b/Makefile index 1521676..7dda68c 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 2aa6e7a..73068ac 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 73a5e83..686bb52 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 0321183..b0786b8 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 35ee270..a55220f 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 081de1f..ca149b9 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 3e210b0..00a7e2e 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 a8fdf37..ed121d9 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 79d93e2..e1fa0d7 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()}') }