refactor: change newFile to take the params struct directly and fill in the blanks
This commit is contained in:
parent
65548e8ec7
commit
a1f36df8b9
19
api/s5/s5.go
19
api/s5/s5.go
|
@ -1678,7 +1678,10 @@ func (s *S5API) downloadFile(jc jape.Context) {
|
||||||
hashBytes = cidDecoded.Hash.HashBytes()
|
hashBytes = cidDecoded.Hash.HashBytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
file := s.newFile(s.protocol, hashBytes, cidDecoded.Type)
|
file := s.newFile(FileParams{
|
||||||
|
Hash: cidDecoded.Hash.HashBytes(),
|
||||||
|
Type: cidDecoded.Type,
|
||||||
|
})
|
||||||
|
|
||||||
if !file.Exists() {
|
if !file.Exists() {
|
||||||
jc.ResponseWriter.WriteHeader(http.StatusNotFound)
|
jc.ResponseWriter.WriteHeader(http.StatusNotFound)
|
||||||
|
@ -1751,14 +1754,12 @@ func (s *S5API) newStorageLocationProvider(hash *encoding.Multihash, excludeSelf
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *S5API) newFile(protocol *s5.S5Protocol, hash []byte, cidTyp types.CIDType) *S5File {
|
func (s *S5API) newFile(params FileParams) *S5File {
|
||||||
return NewFile(FileParams{
|
params.Protocol = s.protocol
|
||||||
Protocol: protocol,
|
params.Metadata = s.metadata
|
||||||
Hash: hash,
|
params.Storage = s.storage
|
||||||
Metadata: s.metadata,
|
|
||||||
Storage: s.storage,
|
return NewFile(params)
|
||||||
Type: cidTyp,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *S5API) pinImportCronJob(cid string, url string, proofUrl string, userId uint) error {
|
func (s *S5API) pinImportCronJob(cid string, url string, proofUrl string, userId uint) error {
|
||||||
|
|
Loading…
Reference in New Issue