Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Release Engineering
Public
srpmproc
Commits
a32ab3d3
Commit
a32ab3d3
authored
Dec 20, 2020
by
Mustafa Gezen
Browse files
upload to storage by checksum
parent
5576abbf
Changes
3
Hide whitespace changes
Inline
Side-by-side
internal/git.go
View file @
a32ab3d3
...
...
@@ -147,7 +147,7 @@ func (g *GitMode) WriteSource(md *modeData) {
log
.
Fatalf
(
"could not open file pointer: %v"
,
err
)
}
hasher
:=
c
ompareHash
(
body
,
hash
)
hasher
:=
C
ompareHash
(
body
,
hash
)
if
hasher
==
nil
{
log
.
Fatal
(
"checksum in metadata does not match dist-git file"
)
}
...
...
internal/process.go
View file @
a32ab3d3
...
...
@@ -154,21 +154,21 @@ func ProcessRPM(pd *ProcessData) {
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
()
_
,
err
=
source
.
hashFunction
.
Write
(
sourceFileBts
)
if
err
!=
nil
{
log
.
Fatalf
(
"could not write bytes to hash function: %v"
,
err
)
}
checksum
:=
source
.
hashFunction
.
Sum
(
nil
)
checksumLine
:=
fmt
.
Sprintf
(
"%s %s
\n
"
,
hex
.
EncodeToString
(
checksum
)
,
sourcePath
)
checksum
:=
hex
.
EncodeToString
(
source
.
hashFunction
.
Sum
(
nil
)
)
checksumLine
:=
fmt
.
Sprintf
(
"%s %s
\n
"
,
checksum
,
sourcePath
)
_
,
err
=
metadata
.
Write
([]
byte
(
checksumLine
))
if
err
!=
nil
{
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
)
...
...
internal/utils.go
View file @
a32ab3d3
...
...
@@ -59,7 +59,7 @@ func ignoredContains(a []*ignoredSource, b string) bool {
// check if content and checksum matches
// returns the hash type if success else nil
func
c
ompareHash
(
content
[]
byte
,
checksum
string
)
hash
.
Hash
{
func
C
ompareHash
(
content
[]
byte
,
checksum
string
)
hash
.
Hash
{
var
hashType
hash
.
Hash
switch
len
(
checksum
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment