[#64] registry: Delete object from the old bucket

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
pull/64/head
Evgenii Stratonikov 2023-05-23 12:38:10 +03:00
parent 52ed0d6d88
commit 4aa9a359b5
1 changed files with 5 additions and 1 deletions

View File

@ -81,10 +81,14 @@ func (o *ObjRegistry) SetObjectStatus(id uint64, oldStatus, newStatus string) er
return fmt.Errorf("bucket doesn't exist: '%s'", oldStatus)
}
objBytes := oldB.Get(encodeId(id))
key := encodeId(id)
objBytes := oldB.Get(key)
if objBytes == nil {
return errors.New("object doesn't exist")
}
if err := oldB.Delete(key); err != nil {
return fmt.Errorf("bucket.Delete: %w", err)
}
obj := new(ObjectInfo)
if err := obj.Unmarshal(objBytes); err != nil {