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

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-05-23 12:38:10 +03:00
parent 52ed0d6d88
commit 4aa9a359b5

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 {