Commit 654c4933 authored by Mustafa Gezen's avatar Mustafa Gezen
Browse files

change blob path, and skip duplicate blob uploads

parent 600ba215
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment