3131package main
3232
3333import (
34+ "crypto/sha256"
3435 "encoding/base64"
36+ "encoding/hex"
3537 "log"
3638 "os"
3739 "strings"
3840 "time"
39- "crypto/sha256"
40- "encoding/hex"
41+
4142 "github.com/spf13/cobra"
4243 "openapi.peridot.resf.org/peridotopenapi"
4344)
@@ -74,12 +75,12 @@ func isFile(path string) bool {
7475 return true
7576}
7677
77- func buildRpmImportMn (c * cobra.Command , args []string ) {
78+ func buildRpmImportMn (_ * cobra.Command , args []string ) {
7879 // Ensure project id exists
7980 projectId := mustGetProjectID ()
8081
81- var skipUpload bool = false
82- var skipImport bool = false
82+ var skipUpload = false
83+ var skipImport = false
8384
8485 if skipStep != "" {
8586 switch strings .ToLower (skipStep ) {
@@ -103,19 +104,22 @@ func buildRpmImportMn(c *cobra.Command, args []string) {
103104 var blobs []string
104105 projectCl := getClient (serviceProject ).(peridotopenapi.ProjectServiceApi )
105106 for _ , arg := range args {
107+
106108 bts , err := os .ReadFile (arg )
107109 errFatal (err )
108- base64EncodedBytes := base64 . StdEncoding . EncodeToString ( bts )
110+
109111 hash := sha256 .Sum256 (bts )
110112 shasum := hex .EncodeToString (hash [:])
111113
112114 if ! skipUpload {
115+ base64EncodedBytes := base64 .StdEncoding .EncodeToString (bts )
113116 _ , _ , err := projectCl .LookasideFileUpload (getContext ()).Body (peridotopenapi.V1LookasideFileUploadRequest {
114117 File : & base64EncodedBytes ,
115118 }).Execute ()
116119 errFatal (err )
117120 log .Printf ("Uploaded %s to lookaside" , arg )
118121 }
122+ log .Printf ("Will upload %s to lookaside for %s" , shasum , arg )
119123 blobs = append (blobs , shasum )
120124 }
121125
0 commit comments