Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: urlencode filename for separate mod targets #47

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func RenameVersion(ctx context.Context, modID string, name string, versionID str
return false, ""
}

return true, fmt.Sprintf("/mods/%s/%s.smod", modID, EncodeName(cleanName)+"-"+version)
return true, fmt.Sprintf("/mods/%s/%s.smod", modID, EncodeName(cleanName+"-"+version))
}

func DeleteMod(ctx context.Context, modID string, name string, versionID string) bool {
Expand Down 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
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
Loading