Compare commits
No commits in common. "435445dda5ac78e5f75510add7e65328517e2956" and "b44b12f85e0104415fa04fe49bc911bb8ea105e5" have entirely different histories.
435445dda5
...
b44b12f85e
|
@ -26,7 +26,7 @@ func Init() {
|
|||
func Upload(r io.ReadSeeker) (model.Upload, error) {
|
||||
var upload model.Upload
|
||||
|
||||
hasher := blake3.New(32, nil)
|
||||
hasher := blake3.New(0, nil)
|
||||
|
||||
_, err := io.Copy(hasher, r)
|
||||
if err != nil {
|
||||
|
@ -34,7 +34,6 @@ func Upload(r io.ReadSeeker) (model.Upload, error) {
|
|||
}
|
||||
|
||||
hashBytes := hasher.Sum(nil)
|
||||
|
||||
hashHex := hex.EncodeToString(hashBytes[:])
|
||||
|
||||
if err != nil {
|
||||
|
@ -46,7 +45,7 @@ func Upload(r io.ReadSeeker) (model.Upload, error) {
|
|||
return upload, err
|
||||
}
|
||||
|
||||
result := db.Get().Where(&model.Upload{Hash: hashHex}).First(&upload)
|
||||
result := db.Get().Where("hash = ?", hashHex).First(&upload)
|
||||
if (result.Error != nil && result.Error.Error() != "record not found") || result.RowsAffected > 0 {
|
||||
err := result.Row().Scan(&upload)
|
||||
if err != nil {
|
||||
|
@ -98,7 +97,7 @@ func Upload(r io.ReadSeeker) (model.Upload, error) {
|
|||
return upload, nil
|
||||
}
|
||||
func Download(hash string) (io.Reader, error) {
|
||||
result := db.Get().Table("uploads").Where(&model.Upload{Hash: hash}).Row()
|
||||
result := db.Get().Table("uploads").Where("hash = ?", hash).Row()
|
||||
|
||||
if result.Err() != nil {
|
||||
return nil, result.Err()
|
||||
|
|
Loading…
Reference in New Issue