Skip to content

Commit

Permalink
stores: revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Mar 12, 2024
1 parent 2a946cb commit 894af25
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions stores/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ func (s *SQLStore) UpdateObject(ctx context.Context, bucket, path, contractSet,
// NOTE: the metadata is not deleted because this delete will cascade,
// if we stop recreating the object we have to make sure to delete the
// object's metadata before trying to recreate it
deleted, err := s.deleteObject(tx, bucket, path)
_, err := s.deleteObject(tx, bucket, path)
if err != nil {
return fmt.Errorf("failed to delete object: %w", err)
}
Expand Down Expand Up @@ -1771,10 +1771,6 @@ func (s *SQLStore) UpdateObject(ctx context.Context, bucket, path, contractSet,
return fmt.Errorf("failed to create user metadata: %w", err)
}

// Delete slabs.
if deleted > 0 {
return pruneSlabs(tx)
}
return nil
})
}
Expand Down Expand Up @@ -2731,7 +2727,13 @@ func (s *SQLStore) deleteObject(tx *gorm.DB, bucket string, path string) (int64,
if tx.Error != nil {
return 0, tx.Error
}
return tx.RowsAffected, nil
numDeleted := tx.RowsAffected
if numDeleted == 0 {
return 0, nil // nothing to prune if no object was deleted
} else if err := pruneSlabs(tx); err != nil {
return numDeleted, err
}
return numDeleted, nil
}

// deleteObjects deletes a batch of objects from the database. The order of
Expand Down

0 comments on commit 894af25

Please sign in to comment.