feat(v0.1.60): sha256-based s3Key for content-addressed cache hit
This commit is contained in:
@@ -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()))
|
||||
|
||||
Reference in New Issue
Block a user