mirror of
https://github.com/rocky-linux/srpmproc.git
synced 2024-06-02 08:10:17 +00:00
upload to storage by checksum
This commit is contained in:
parent
5576abbffc
commit
a32ab3d34f
|
@ -147,7 +147,7 @@ func (g *GitMode) WriteSource(md *modeData) {
|
||||||
log.Fatalf("could not open file pointer: %v", err)
|
log.Fatalf("could not open file pointer: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasher := compareHash(body, hash)
|
hasher := CompareHash(body, hash)
|
||||||
if hasher == nil {
|
if hasher == nil {
|
||||||
log.Fatal("checksum in metadata does not match dist-git file")
|
log.Fatal("checksum in metadata does not match dist-git file")
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,21 +154,21 @@ func ProcessRPM(pd *ProcessData) {
|
||||||
log.Fatalf("could not read the whole of ignored source file: %v", err)
|
log.Fatalf("could not read the whole of ignored source file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
path := fmt.Sprintf("%s-%s/%s", rpmFile.Name(), md.pushBranch, source.name)
|
|
||||||
pd.BlobStorage.Write(path, sourceFileBts)
|
|
||||||
log.Printf("wrote %s to blob storage", path)
|
|
||||||
|
|
||||||
source.hashFunction.Reset()
|
source.hashFunction.Reset()
|
||||||
_, err = source.hashFunction.Write(sourceFileBts)
|
_, err = source.hashFunction.Write(sourceFileBts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("could not write bytes to hash function: %v", err)
|
log.Fatalf("could not write bytes to hash function: %v", err)
|
||||||
}
|
}
|
||||||
checksum := source.hashFunction.Sum(nil)
|
checksum := hex.EncodeToString(source.hashFunction.Sum(nil))
|
||||||
checksumLine := fmt.Sprintf("%s %s\n", hex.EncodeToString(checksum), sourcePath)
|
checksumLine := fmt.Sprintf("%s %s\n", checksum, sourcePath)
|
||||||
_, err = metadata.Write([]byte(checksumLine))
|
_, err = metadata.Write([]byte(checksumLine))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("could not write to metadata file: %v", err)
|
log.Fatalf("could not write to metadata file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path := fmt.Sprintf("%s-%s/%s", rpmFile.Name(), md.pushBranch, checksum)
|
||||||
|
pd.BlobStorage.Write(path, sourceFileBts)
|
||||||
|
log.Printf("wrote %s to blob storage", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = w.Add(metadataFile)
|
_, err = w.Add(metadataFile)
|
||||||
|
|
|
@ -59,7 +59,7 @@ func ignoredContains(a []*ignoredSource, b string) bool {
|
||||||
|
|
||||||
// check if content and checksum matches
|
// check if content and checksum matches
|
||||||
// returns the hash type if success else nil
|
// returns the hash type if success else nil
|
||||||
func compareHash(content []byte, checksum string) hash.Hash {
|
func CompareHash(content []byte, checksum string) hash.Hash {
|
||||||
var hashType hash.Hash
|
var hashType hash.Hash
|
||||||
|
|
||||||
switch len(checksum) {
|
switch len(checksum) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user