mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-14 03:01:48 +00:00
@@ -146,7 +146,8 @@ func FetchRepository(
|
||||
for _, oldManifestEntry := range oldManifest.GetContents() {
|
||||
if hash, ok := plumbing.FromHex(oldManifestEntry.GetGitHash()); ok {
|
||||
if manifestEntry, found := blobsNeeded[hash]; found {
|
||||
CopyProtoMessage(manifestEntry, oldManifestEntry)
|
||||
manifestEntry.Reset()
|
||||
proto.Merge(manifestEntry, oldManifestEntry)
|
||||
dataBytesFromOldManifest += oldManifestEntry.GetOriginalSize()
|
||||
delete(blobsNeeded, hash)
|
||||
}
|
||||
|
||||
18
src/util.go
18
src/util.go
@@ -4,8 +4,6 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type BoundedReader struct {
|
||||
@@ -87,19 +85,3 @@ func getMediaType(mimeType string) (mediaType string) {
|
||||
mediaType = strings.TrimSpace(strings.ToLower(mediaType))
|
||||
return
|
||||
}
|
||||
|
||||
// Copying Protobuf messages like `*dest = *src` causes a lock to be copied, which is unsound.
|
||||
// Copying Protobuf messages field-wise is fragile: adding a new field to the schema does not
|
||||
// cause a diagnostic to be emitted pointing to the copy site, making it easy to miss updates.
|
||||
// Serializing and deserializing is reliable and breaks referential links.
|
||||
func CopyProtoMessage(dest, src proto.Message) {
|
||||
data, err := proto.Marshal(src)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = proto.Unmarshal(data, dest)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user