Compare commits
No commits in common. "a16390ccc139f13cf6e20b7b48188240d48de180" and "b267ace01704d80c27a6abce2df65d9c6f3de8b0" have entirely different histories.
a16390ccc1
...
b267ace017
35
api/s5/s5.go
35
api/s5/s5.go
|
@ -865,13 +865,7 @@ func (s *S5API) accountPins(jc jape.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
tusRet, err := s.tusHandler.Uploads(jc.Request.Context(), userID)
|
||||
if err != nil {
|
||||
s.sendErrorResponse(jc, NewS5Error(ErrKeyStorageOperationFailed, err))
|
||||
return
|
||||
}
|
||||
|
||||
pins := make([]AccountPin, len(pinsRet)+len(tusRet))
|
||||
pins := make([]AccountPin, len(pinsRet))
|
||||
|
||||
for i, pin := range pinsRet {
|
||||
cid, err := encoding.CIDFromHash(pin.Upload.Hash, pin.Upload.Size, types.CIDTypeRaw, types.HashTypeBlake3)
|
||||
|
@ -892,33 +886,6 @@ func (s *S5API) accountPins(jc jape.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
for i, tus := range tusRet {
|
||||
size, err := s.tusHandler.GetUploadSize(jc.Request.Context(), tus.Hash)
|
||||
if err != nil {
|
||||
s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err))
|
||||
return
|
||||
}
|
||||
|
||||
cid, err := encoding.CIDFromHash(tus.Hash, uint64(size), types.CIDTypeRaw, types.HashTypeBlake3)
|
||||
if err != nil {
|
||||
s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err))
|
||||
return
|
||||
}
|
||||
|
||||
base64Url, err := cid.Hash.ToBase64Url()
|
||||
if err != nil {
|
||||
s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err))
|
||||
return
|
||||
}
|
||||
|
||||
pins[i+len(pinsRet)] = AccountPin{
|
||||
Hash: base64Url,
|
||||
Size: uint64(size),
|
||||
PinnedAt: tus.CreatedAt,
|
||||
MimeType: tus.MimeType,
|
||||
}
|
||||
}
|
||||
|
||||
jc.Encode(&AccountPinResponse{Pins: pins})
|
||||
}
|
||||
|
||||
|
|
|
@ -175,17 +175,6 @@ func (t *TusHandler) UploadExists(ctx context.Context, hash []byte) (bool, model
|
|||
return result.RowsAffected > 0, upload
|
||||
}
|
||||
|
||||
func (t *TusHandler) Uploads(ctx context.Context, uploaderID uint) ([]models.TusUpload, error) {
|
||||
var uploads []models.TusUpload
|
||||
result := t.db.WithContext(ctx).Model(&models.TusUpload{}).Where(&models.TusUpload{UploaderID: uploaderID}).Find(&uploads)
|
||||
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
|
||||
return uploads, nil
|
||||
}
|
||||
|
||||
func (t *TusHandler) CreateUpload(ctx context.Context, hash []byte, uploadID string, uploaderID uint, uploaderIP string, protocol string) (*models.TusUpload, error) {
|
||||
upload := &models.TusUpload{
|
||||
Hash: hash,
|
||||
|
|
Loading…
Reference in New Issue