Skip to content

Commit

Permalink
fix: urlencode filename for separate mod targets
Browse files Browse the repository at this point in the history
When a mod's name contains characters that should be urlencoded,
any newly-uploaded versions cannot be download because of some
errors regarding the URL being invalid. Make sure the returned key
is urlencoded for consistency with the rest of the codebase.
  • Loading branch information
Th3Fanbus authored Mar 5, 2024
1 parent 867a34d commit 4c5629d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ func SeparateModTarget(ctx context.Context, body []byte, modID, name, modVersion

zipWriter.Close()

key := fmt.Sprintf("/mods/%s/%s.smod", modID, cleanName+"-"+target+"-"+modVersion)
filename := cleanName+"-"+target+"-"+modVersion

Check failure on line 407 in storage/storage.go

View workflow job for this annotation

GitHub Actions / Lint

File is not `gofumpt`-ed (gofumpt)
key := fmt.Sprintf("/mods/%s/%s.smod", modID, filename)

_, err = storage.Put(ctx, key, bytes.NewReader(buf.Bytes()))
if err != nil {
Expand All @@ -415,7 +416,8 @@ func SeparateModTarget(ctx context.Context, body []byte, modID, name, modVersion
hash := sha256.New()
hash.Write(buf.Bytes())

return true, key, hex.EncodeToString(hash.Sum(nil)), int64(buf.Len())
encodedKey := fmt.Sprintf("/mods/%s/%s.smod", modID, EncodeName(filename))
return true, encodedKey, hex.EncodeToString(hash.Sum(nil)), int64(buf.Len())
}

func copyModFileToArchZip(file *zip.File, zipWriter *zip.Writer, newName string) error {
Expand Down

0 comments on commit 4c5629d

Please sign in to comment.