mirror of
https://github.com/rocky-linux/srpmproc.git
synced 2024-12-04 18:36:26 +00:00
change blob path, and skip duplicate blob uploads
This commit is contained in:
parent
600ba21558
commit
654c4933df
@ -208,6 +208,8 @@ func ProcessRPM(pd *ProcessData) {
|
||||
executePatchesRpm(pd, md)
|
||||
}
|
||||
|
||||
// already uploaded blobs are skipped
|
||||
var alreadyUploadedBlobs []string
|
||||
// get ignored files hash and add to .{name}.metadata
|
||||
metadataFile := fmt.Sprintf(".%s.metadata", rpmFile.Name())
|
||||
metadata, err := w.Filesystem.Create(metadataFile)
|
||||
@ -238,8 +240,12 @@ func ProcessRPM(pd *ProcessData) {
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("%s/%s", rpmFile.Name(), checksum)
|
||||
if strContains(alreadyUploadedBlobs, path) {
|
||||
continue
|
||||
}
|
||||
pd.BlobStorage.Write(path, sourceFileBts)
|
||||
log.Printf("wrote %s to blob storage", path)
|
||||
alreadyUploadedBlobs = append(alreadyUploadedBlobs, path)
|
||||
}
|
||||
|
||||
_, err = w.Add(metadataFile)
|
||||
|
@ -57,6 +57,16 @@ func ignoredContains(a []*ignoredSource, b string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func strContains(a []string, b string) bool {
|
||||
for _, val := range a {
|
||||
if val == b {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// check if content and checksum matches
|
||||
// returns the hash type if success else nil
|
||||
func CompareHash(content []byte, checksum string) hash.Hash {
|
||||
|
Loading…
Reference in New Issue
Block a user