feat(v0.1.60): sha256-based s3Key for content-addressed cache hit

This commit is contained in:
Naeel
2026-03-23 06:57:18 +03:00
parent c033adec11
commit 2e7cd7f4f7
3 changed files with 18 additions and 7 deletions
+6 -1
View File
@@ -8,7 +8,9 @@
package handler
import (
"crypto/sha256"
"encoding/json"
"fmt"
"io"
"net/http"
"time"
@@ -383,7 +385,10 @@ func (h *Handler) UploadServiceCode(w http.ResponseWriter, r *http.Request) {
return
}
version := time.Now().Format("20060102150405")
// Версия = sha256(загруженный zip). Одинаковый код → одинаковый s3Key → cache hit.
// Изменился код → новый хеш → новый build.
zipHash := sha256.Sum256(zipData)
version := fmt.Sprintf("%x", zipHash[:])[:16]
s3Key, err := h.S3.UploadContext(r.Context(), ns, name, version, buf, int64(buf.Len()))
if err != nil {
writeJSON(w, http.StatusInternalServerError, errResp("upload to S3: "+err.Error()))