From 78b477fb9254df38656a8e69f4e9989ce8f5b131 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Wed, 13 Apr 2022 22:20:05 +0200 Subject: [PATCH] Removed deprecated err.msg & err.code --- src/cron/cron.v | 3 --- src/cron/daemon/daemon.v | 7 ++++--- src/env/env.v | 2 +- src/repo/repo.v | 6 +++--- src/server/git.v | 4 ++-- src/server/routes.v | 6 +++--- src/server/server.v | 2 +- src/web/web.v | 8 ++++---- 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/cron/cron.v b/src/cron/cron.v index d8b4d95..cb5bcd7 100644 --- a/src/cron/cron.v +++ b/src/cron/cron.v @@ -1,9 +1,6 @@ module cron -import git -import time import log -import util import cron.daemon import cron.expression diff --git a/src/cron/daemon/daemon.v b/src/cron/daemon/daemon.v index ede9320..9931d4f 100644 --- a/src/cron/daemon/daemon.v +++ b/src/cron/daemon/daemon.v @@ -58,6 +58,7 @@ pub fn init_daemon(logger log.Log, address string, api_key string, base_image st pub fn (mut d Daemon) run() ? { println(d.queue) + println('i am running') } fn (mut d Daemon) renew_repos() ? { @@ -81,12 +82,12 @@ fn (mut d Daemon) renew_queue() ? { new_queue.insert(d.queue.pop() ?) } - println('hey') - println(d.repos_map) + eprintln('hey') + eprintln(d.repos_map) // For each repository in repos_map, parse their cron expression (or use // the default one if not present) & add them to the queue for id, repo in d.repos_map { - println('hey') + eprintln('hey') ce := parse_expression(repo.schedule) or { d.global_schedule } // A repo that can't be scheduled will just be skipped for now timestamp := ce.next(now) or { continue } diff --git a/src/env/env.v b/src/env/env.v index 88f1650..b2b5f44 100644 --- a/src/env/env.v +++ b/src/env/env.v @@ -36,7 +36,7 @@ fn get_env_var(field_name string) ?string { // Otherwise, we process the file return os.read_file(env_file) or { - error('Failed to read file defined in $env_file_name: ${err.msg}.') + error('Failed to read file defined in $env_file_name: ${err.msg()}.') } } diff --git a/src/repo/repo.v b/src/repo/repo.v index f439f58..e27e232 100644 --- a/src/repo/repo.v +++ b/src/repo/repo.v @@ -30,11 +30,11 @@ pub: // new creates a new RepoGroupManager & creates the directories as needed pub fn new(repos_dir string, pkg_dir string, default_arch string) ?RepoGroupManager { if !os.is_dir(repos_dir) { - os.mkdir_all(repos_dir) or { return error('Failed to create repos directory: $err.msg') } + os.mkdir_all(repos_dir) or { return error('Failed to create repos directory: $err.msg()') } } if !os.is_dir(pkg_dir) { - os.mkdir_all(pkg_dir) or { return error('Failed to create package directory: $err.msg') } + os.mkdir_all(pkg_dir) or { return error('Failed to create package directory: $err.msg()') } } return RepoGroupManager{ @@ -50,7 +50,7 @@ pub fn new(repos_dir string, pkg_dir string, default_arch string) ?RepoGroupMana // the right subdirectories in r.pkg_dir if it was successfully added. pub fn (r &RepoGroupManager) add_pkg_from_path(repo string, pkg_path string) ?RepoAddResult { pkg := package.read_pkg_archive(pkg_path) or { - return error('Failed to read package file: $err.msg') + return error('Failed to read package file: $err.msg()') } added := r.add_pkg_in_repo(repo, pkg) ? diff --git a/src/server/git.v b/src/server/git.v index 2a682d8..a9d6f50 100644 --- a/src/server/git.v +++ b/src/server/git.v @@ -16,7 +16,7 @@ fn (mut app App) get_repos() web.Result { repos := rlock app.git_mutex { git.read_repos(app.conf.repos_file) or { - app.lerror('Failed to read repos file: $err.msg') + app.lerror('Failed to read repos file: $err.msg()') return app.status(http.Status.internal_server_error) } @@ -55,7 +55,7 @@ fn (mut app App) post_repo() web.Result { } new_repo := git.repo_from_params(app.query) or { - return app.json(http.Status.bad_request, new_response(err.msg)) + return app.json(http.Status.bad_request, new_response(err.msg())) } id := rand.uuid_v4() diff --git a/src/server/routes.v b/src/server/routes.v index 138f253..4f6c4f0 100644 --- a/src/server/routes.v +++ b/src/server/routes.v @@ -87,15 +87,15 @@ fn (mut app App) put_package(repo string) web.Result { } res := app.repo.add_pkg_from_path(repo, pkg_path) or { - app.lerror('Error while adding package: $err.msg') + app.lerror('Error while adding package: $err.msg()') - os.rm(pkg_path) or { app.lerror("Failed to remove download '$pkg_path': $err.msg") } + os.rm(pkg_path) or { app.lerror("Failed to remove download '$pkg_path': $err.msg()") } return app.json(http.Status.internal_server_error, new_response('Failed to add package.')) } if !res.added { - os.rm(pkg_path) or { app.lerror("Failed to remove download '$pkg_path': $err.msg") } + os.rm(pkg_path) or { app.lerror("Failed to remove download '$pkg_path': $err.msg()") } app.lwarn("Duplicate package '$res.pkg.full_name()' in repo '$repo'.") diff --git a/src/server/server.v b/src/server/server.v index 5bf9a87..c4317c5 100644 --- a/src/server/server.v +++ b/src/server/server.v @@ -45,7 +45,7 @@ pub fn server(conf Config) ? { // This also creates the directories if needed repo := repo.new(conf.repos_dir, conf.pkg_dir, conf.default_arch) or { - logger.error(err.msg) + logger.error(err.msg()) exit(1) } diff --git a/src/web/web.v b/src/web/web.v index 000c6a6..688f854 100644 --- a/src/web/web.v +++ b/src/web/web.v @@ -249,7 +249,7 @@ pub fn (mut ctx Context) file(f_path string) Result { // ext := os.file_ext(f_path) // data := os.read_file(f_path) or { - // eprint(err.msg) + // eprint(err.msg()) // ctx.server_error(500) // return Result{} // } @@ -267,7 +267,7 @@ pub fn (mut ctx Context) file(f_path string) Result { file_size := os.file_size(f_path) file := os.open(f_path) or { - eprintln(err.msg) + eprintln(err.msg()) ctx.server_error(500) return Result{} } @@ -361,7 +361,7 @@ interface DbInterface { // run runs the app [manualfree] pub fn run(global_app &T, port int) { - mut l := net.listen_tcp(.ip6, ':$port') or { panic('failed to listen $err.code $err') } + mut l := net.listen_tcp(.ip6, ':$port') or { panic('failed to listen $err.code() $err') } // Parsing methods attributes mut routes := map[string]Route{} @@ -393,7 +393,7 @@ pub fn run(global_app &T, port int) { request_app.Context = global_app.Context // copy the context ref that contains static files map etc mut conn := l.accept() or { // failures should not panic - eprintln('accept() failed with error: $err.msg') + eprintln('accept() failed with error: $err.msg()') continue } go handle_conn(mut conn, mut request_app, routes)