From 96416585bcc8b4da733cb9834bec919a4ebbd7ca Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Mon, 21 Feb 2022 17:18:14 +0100 Subject: [PATCH] Added some error messages; updated changelog --- CHANGELOG.md | 14 ++++++++++++++ src/docker/docker.v | 14 ++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3824088..1166377 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://git.rustybever.be/Chewing_Bever/vieter) +## Added + +* Very basic build system + * Build is triggered by separate cron container + * Packages build on cron container's system + * Packages are always rebuilt, even if they haven't changed + * Hardcoded planning of builds + * Builds are sequential + +## Fixed + +* Each package can now only have one version in the repository at once + (required by Pacman) + ## [0.1.0](https://git.rustybever.be/Chewing_Bever/vieter/src/tag/0.1.0) ### Changed diff --git a/src/docker/docker.v b/src/docker/docker.v index b68a7b4..9c93986 100644 --- a/src/docker/docker.v +++ b/src/docker/docker.v @@ -11,7 +11,7 @@ const buf_len = 1024 fn send(req &string) ?http.Response { // Open a connection to the socket - mut s := unix.connect_stream(docker.socket) ? + mut s := unix.connect_stream(docker.socket) or { return error('Failed to connect to socket ${docker.socket}.') } defer { // This or is required because otherwise, the V compiler segfaults for @@ -21,7 +21,7 @@ fn send(req &string) ?http.Response { } // Write the request to the socket - s.write_string(req) ? + s.write_string(req) or { return error('Failed to write request to socket ${docker.socket}.') } s.wait_for_write() ? @@ -30,7 +30,7 @@ fn send(req &string) ?http.Response { mut res := []byte{} for { - c = s.read(mut buf) or { return error('Failed to read data from socket.') } + c = s.read(mut buf) or { return error('Failed to read data from socket ${docker.socket}.') } res << buf[..c] if c < docker.buf_len { @@ -38,20 +38,22 @@ fn send(req &string) ?http.Response { } } - // If the response isn't a chunked reply, we return early - parsed := http.parse_response(res.bytestr()) ? + // After reading the first part of the response, we parse it into an HTTP + // response. If it isn't chunked, we return early with the data. + parsed := http.parse_response(res.bytestr()) or { return error('Failed to parse HTTP response from socket ${docker.socket}.') } if parsed.header.get(http.CommonHeader.transfer_encoding) or { '' } != 'chunked' { return parsed } // We loop until we've encountered the end of the chunked response + // A chunked HTTP response always ends with '0\r\n\r\n'. for res.len < 5 || res#[-5..] != [byte(`0`), `\r`, `\n`, `\r`, `\n`] { // Wait for the server to respond s.wait_for_write() ? for { - c = s.read(mut buf) or { return error('Failed to read data from socket.') } + c = s.read(mut buf) or { return error('Failed to read data from socket ${docker.socket}.') } res << buf[..c] if c < docker.buf_len {