@@ -492,6 +492,8 @@ func (s *dsObjectStore) GetInboundLinksByID(id string) ([]string, error) {
492
492
return findInboundLinks (txn , id )
493
493
}
494
494
495
+ // GetDetails returns empty struct without errors in case details are not found
496
+ // todo: get rid of this or change the name method!
495
497
func (s * dsObjectStore ) GetDetails (id string ) (* model.ObjectDetails , error ) {
496
498
txn , err := s .ds .NewTransaction (true )
497
499
if err != nil {
@@ -774,20 +776,25 @@ func (s *dsObjectStore) GetObjectType(url string) (*model.ObjectType, error) {
774
776
if strings .HasPrefix (url , addr .BundledObjectTypeURLPrefix ) {
775
777
return bundle .GetTypeByUrl (url )
776
778
}
777
- objectInfos , err := s .GetByIDs (url )
779
+
780
+ details , err := s .GetDetails (url )
778
781
if err != nil {
779
782
return nil , err
780
783
}
781
- if len (objectInfos ) == 0 {
782
- return nil , fmt .Errorf ("object type not found in the index" )
784
+
785
+ if pbtypes .IsStructEmpty (details .GetDetails ()) {
786
+ return nil , ErrObjectNotFound
787
+ }
788
+
789
+ if pbtypes .GetBool (details .GetDetails (), bundle .RelationKeyIsDeleted .String ()) {
790
+ return nil , fmt .Errorf ("type was removed" )
783
791
}
784
- details := objectInfos [0 ].Details
785
792
786
- if pbtypes .GetString (details , bundle .RelationKeyType .String ()) != bundle .TypeKeyObjectType .URL () {
793
+ if pbtypes .GetString (details . Details , bundle .RelationKeyType .String ()) != bundle .TypeKeyObjectType .URL () {
787
794
return nil , fmt .Errorf ("object %s is not an object type" , url )
788
795
}
789
796
790
- return s .extractObjectTypeFromDetails (details , url ), nil
797
+ return s .extractObjectTypeFromDetails (details . Details , url ), nil
791
798
}
792
799
793
800
func (s * dsObjectStore ) extractObjectTypeFromDetails (details * types.Struct , url string ) * model.ObjectType {
0 commit comments