@@ -15,8 +15,8 @@ import (
1515)
1616
1717const (
18- checksumFile = "sha256sum.txt"
1918 binaryPrefix = "oadp-vmdp_"
19+ licenseFile = "LICENSE"
2020 bytesPerMB = 1024 * 1024
2121 minPlatformParts = 3
2222 readTimeout = 10 * time .Second
@@ -82,7 +82,7 @@ func main() {
8282 }
8383}
8484
85- // listBinaryFiles returns all downloadable files (excludes sha256sum.txt and . sha256 sidecars).
85+ // listBinaryFiles returns all downloadable binaries (excludes . sha256 sidecars and LICENSE ).
8686func listBinaryFiles () ([]string , error ) {
8787 entries , err := os .ReadDir (archiveDir )
8888 if err != nil {
@@ -99,49 +99,31 @@ func listBinaryFiles() ([]string, error) {
9999 name := e .Name ()
100100
101101 if strings .HasPrefix (name , binaryPrefix ) &&
102- ! strings .HasSuffix (name , ".sha256" ) &&
103- name != checksumFile {
102+ ! strings .HasSuffix (name , ".sha256" ) {
104103 files = append (files , filepath .Join (archiveDir , name ))
105104 }
106105 }
107106
108107 return files , nil
109108}
110109
111- // readChecksum reads a SHA256 checksum from a .sha256 sidecar file or
112- // falls back to looking up the filename in sha256sum.txt.
110+ // readChecksum reads a SHA256 checksum from a per-file .sha256 sidecar file.
113111func readChecksum (filePath string ) string {
114- // Try per-file .sha256 sidecar first (oadp-cli style).
115112 data , err := os .ReadFile (filePath + ".sha256" ) //nolint:gosec // path is constructed from archiveDir constant
116- if err == nil {
117- fields := strings .Fields (string (data ))
118- if len (fields ) > 0 {
119- return fields [0 ]
120- }
121- }
122-
123- // Fall back to sha256sum.txt.
124- sumFile := filepath .Join (filepath .Dir (filePath ), checksumFile )
125-
126- data , err = os .ReadFile (sumFile ) //nolint:gosec // path is constructed from archiveDir constant
127113 if err != nil {
128114 return ""
129115 }
130116
131- base := filepath .Base (filePath )
132-
133- for line := range strings .SplitSeq (strings .TrimSpace (string (data )), "\n " ) {
134- fields := strings .Fields (line )
135- if len (fields ) == 2 && fields [1 ] == base {
136- return fields [0 ]
137- }
117+ fields := strings .Fields (string (data ))
118+ if len (fields ) > 0 {
119+ return fields [0 ]
138120 }
139121
140122 return ""
141123}
142124
143125// parsePlatform extracts OS and architecture from a filename like
144- // oadp-vmdp_v1.0.0_linux_amd64 or oadp-vmdp_v1.0.0_windows_arm64 .exe.
126+ // oadp-vmdp_linux_amd64 or oadp-vmdp_windows_arm64 .exe.
145127func parsePlatform (filename string ) (string , string ) {
146128 name := strings .TrimSuffix (filename , ".exe" )
147129
@@ -160,6 +142,11 @@ func listBinaries(w http.ResponseWriter, _ *http.Request) {
160142 return
161143 }
162144
145+ hasLicense := false
146+ if _ , err := os .Stat (filepath .Join (archiveDir , licenseFile )); err == nil {
147+ hasLicense = true
148+ }
149+
163150 var linuxFiles , windowsFiles []archiveFile
164151
165152 for _ , file := range files {
@@ -187,7 +174,8 @@ func listBinaries(w http.ResponseWriter, _ *http.Request) {
187174 data := struct {
188175 LinuxFiles []archiveFile
189176 WindowsFiles []archiveFile
190- }{linuxFiles , windowsFiles }
177+ HasLicense bool
178+ }{linuxFiles , windowsFiles , hasLicense }
191179
192180 w .Header ().Set ("Content-Type" , "text/html" )
193181
@@ -199,13 +187,13 @@ func listBinaries(w http.ResponseWriter, _ *http.Request) {
199187func downloadBinary (w http.ResponseWriter , r * http.Request ) {
200188 filename := filepath .Base (r .URL .Path [len ("/download/" ):])
201189
202- // Security: only allow known file prefixes and the checksum file.
190+ // Security: only allow known file prefixes and the LICENSE file.
203191 if filepath .Dir (filename ) != "." {
204192 http .Error (w , "Invalid filename" , http .StatusBadRequest )
205193 return
206194 }
207195
208- if ! strings .HasPrefix (filename , binaryPrefix ) && filename != checksumFile {
196+ if ! strings .HasPrefix (filename , binaryPrefix ) && filename != licenseFile {
209197 http .Error (w , "Invalid filename" , http .StatusBadRequest )
210198 return
211199 }
@@ -219,7 +207,7 @@ func downloadBinary(w http.ResponseWriter, r *http.Request) {
219207
220208 w .Header ().Set ("Content-Disposition" , "attachment; filename=" + filename )
221209
222- if filename == checksumFile {
210+ if filename == licenseFile {
223211 w .Header ().Set ("Content-Type" , "text/plain" )
224212 } else {
225213 w .Header ().Set ("Content-Type" , "application/octet-stream" )
0 commit comments