[mirror] Scalable static site server for Git forges (like GitHub Pages)

Fill in `git_hash` for regular files in archive uploads.

This will be used for incremental archive uploads.

+9
+9
src/manifest.go
··· 17 17 "time" 18 18 19 19 "github.com/c2h5oh/datasize" 20 + "github.com/go-git/go-git/v6/plumbing" 21 + format "github.com/go-git/go-git/v6/plumbing/format/config" 20 22 "github.com/klauspost/compress/zstd" 21 23 "github.com/prometheus/client_golang/prometheus" 22 24 "github.com/prometheus/client_golang/prometheus/promauto" ··· 103 105 } 104 106 105 107 func AddFile(manifest *Manifest, path string, data []byte) *Entry { 108 + // Fill in `git_hash` even for files not originating from git using the SHA256 algorithm; 109 + // we use this primarily for incremental archive uploads, but when support for git SHA256 110 + // repositories is complete, archive uploads and git checkouts will have cross-support for 111 + // incremental updates. 112 + hasher := plumbing.NewHasher(format.SHA256, plumbing.BlobObject, int64(len(data))) 113 + hasher.Write(data) 106 114 entry := NewManifestEntry(Type_InlineFile, data) 115 + entry.GitHash = proto.String(hasher.Sum().String()) 107 116 manifest.Contents[path] = entry 108 117 return entry 109 118 }