From 1eff80302b4b804f4d5d098c5dacb60ba4a33756 Mon Sep 17 00:00:00 2001 From: Brian Bockelman Date: Sat, 3 Jun 2023 14:50:09 -0500 Subject: [PATCH] Various fixes from the linter --- cmd/osdf_stage/main.go | 5 ++--- handle_http.go | 2 +- handle_ingest.go | 4 ++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/osdf_stage/main.go b/cmd/osdf_stage/main.go index a15baa0..5ab399a 100644 --- a/cmd/osdf_stage/main.go +++ b/cmd/osdf_stage/main.go @@ -73,8 +73,7 @@ Terminology: correspondings to the files in the origin prefix. Example: /mnt/cephfs/protected - Shadow prefix: Where in the OSDF namespace the resulting files should - be uploaded. Example: osdf://osg-connect-shadow/protected -`); + be uploaded. Example: osdf://osg-connect-shadow/protected`); os.Exit(0) } else { log.Errorln(err) @@ -152,7 +151,7 @@ Terminology: log.Errorln("TransferInput is not a string") os.Exit(1) } - re := regexp.MustCompile("[,\\s]+") + re := regexp.MustCompile(`[,\s]+`) for _, source := range re.Split(inputListStr, -1) { log.Debugln("Examining transfer input file", source) if (strings.HasPrefix(source, options.MountPrefix)) { diff --git a/handle_http.go b/handle_http.go index 5ed47e0..4cd4917 100644 --- a/handle_http.go +++ b/handle_http.go @@ -971,7 +971,7 @@ func StatHttp(dest *url.URL, namespace Namespace) (uint64, error) { } contentLength, err := strconv.ParseInt(contentLengthStr, 10, 64) if err != nil { - log.Errorln("Unable to parse Content-Length header value (%s) as integer: %s", contentLengthStr, err) + log.Errorf("Unable to parse Content-Length header value (%s) as integer: %s", contentLengthStr, err) return 0, err } return uint64(contentLength), nil diff --git a/handle_ingest.go b/handle_ingest.go index d1c5886..7b504fa 100644 --- a/handle_ingest.go +++ b/handle_ingest.go @@ -35,6 +35,7 @@ func generate_destination(filePath string, originPrefix string, shadowOriginPref } func DoShadowIngest(sourceFile string, originPrefix string, shadowOriginPrefix string) (int64, string, error) { + // After each transfer attempt, we'll check to see if the local file was modified. If so, we'll re-upload. for idx := 0; idx < 10; idx++ { shadowFile, localSize, err := generate_destination(sourceFile, originPrefix, shadowOriginPrefix) log.Debugln("Resulting shadow URL:", shadowFile) @@ -85,6 +86,9 @@ func DoShadowIngest(sourceFile string, originPrefix string, shadowOriginPrefix s } uploadBytes, err := DoStashCPSingle(sourceFile, shadowFile, methods, false) + if err != nil { + return 0, "", err + } // See if the file was modified while we were uploading; if not, we'll return success shadowFilePost, _, err := generate_destination(sourceFile, originPrefix, shadowOriginPrefix)