From fc5bb2534ad532e374405d03514160c68de1b9cf Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Mon, 11 Nov 2024 11:03:25 +0000 Subject: [PATCH] Add additional logging to debug PIS update process --- helpers/config.go | 2 +- pis/check.go | 1 + pis/update.go | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/helpers/config.go b/helpers/config.go index 4376dfd..d4fcec8 100644 --- a/helpers/config.go +++ b/helpers/config.go @@ -5,7 +5,7 @@ import ( ) // Version Constants -const versionNum string = "2024.10.2" +const versionNum string = "2024.11.1" const versionSuffix string = "" const Version string = versionNum + versionSuffix diff --git a/pis/check.go b/pis/check.go index 2af5c21..2978cc7 100644 --- a/pis/check.go +++ b/pis/check.go @@ -14,6 +14,7 @@ import ( // Checks the Gitea API for the latest release and compares to metadata in the database // to determine if a PIS update is required. func Check() { + log.Info("PIS Update Check started") repoName := "data" repoOwner := "owlboard" baseUrl := "https://git.fjla.uk" diff --git a/pis/update.go b/pis/update.go index ee64df5..597f1c7 100644 --- a/pis/update.go +++ b/pis/update.go @@ -21,6 +21,7 @@ const ( // Downloads the release tarball, extracts then applies to database func runUpdate(tarballUrl string) error { + log.Info("PIS Update Process started") err := downloadFile(tarballUrl, destPath) if err != nil { return err @@ -31,11 +32,13 @@ func runUpdate(tarballUrl string) error { if err != nil { return err } + log.Info("Saved PIS Release to disk") defer file.Close() if err := extractFiles(file, extractPath); err != nil { return err } + log.Info("Extracted PIS Release") // Load YAML to string pisData, err := extractYamlData(extractPath) @@ -47,6 +50,7 @@ func runUpdate(tarballUrl string) error { if err != nil { return err } + log.Info("Loaded PIS Files to Slice") fmt.Println(&pisSlice) /* @@ -78,6 +82,7 @@ func downloadFile(url, filepath string) error { if err != nil { return err } + log.Info("PIS Release downloaded") defer resp.Body.Close() @@ -99,6 +104,7 @@ func extractFiles(gzipStream io.Reader, dest string) error { return err } defer uncompressedStream.Close() + log.Info("Extracting PIS File") tarReader := tar.NewReader(uncompressedStream) @@ -189,4 +195,5 @@ func cleanupFiles(paths ...string) { log.Warn("Error removing file", zap.String("path", path), zap.Error(err)) } } + log.Info("Removed PIS Release files") }