Removed deprecated err.msg & err.code
ci/woodpecker/push/arch unknown status Details
ci/woodpecker/push/docker unknown status Details
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details

pull/134/head
Jef Roosens 2022-04-13 22:20:05 +02:00
parent f7e1aba30b
commit 78b477fb92
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
8 changed files with 18 additions and 20 deletions

View File

@ -1,9 +1,6 @@
module cron
import git
import time
import log
import util
import cron.daemon
import cron.expression

View File

@ -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 }

2
src/env/env.v vendored
View File

@ -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()}.')
}
}

View File

@ -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) ?

View File

@ -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()

View File

@ -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'.")

View File

@ -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)
}

View File

@ -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<T>(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<T>(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<T>(mut conn, mut request_app, routes)