anchor.diff:                      ets:insert(TableName, {LinkName, undefined}),
                       AccIn
               end
  -    end, []).
  +    end, []),
  +
  +    First = ets:first(TableName),
  +    filter_children_in_db(First, FileCtx, UserCtx, TableName).
  +
  +%%-------------------------------------------------------------------
  +%% @private
  +%% @doc
  +%% Iterates over all children (in db ets) and deletes files/dirs without
  +%% location doc.
  +%% @end
  +%%-------------------------------------------------------------------
  +-spec filter_children_in_db(key(), file_ctx:ctx(), user_ctx:ctx(), atom()) -> ok.
  +filter_children_in_db('$end_of_table', _FileCtx, _UserCtx, _TableName) ->
  +    ok;
  +filter_children_in_db(LinkName, FileCtx, UserCtx, TableName) ->
  +    {ChildCtx, _} = file_ctx:get_child(FileCtx, LinkName, UserCtx),
  +    {IsDir, ChildCtx2} = file_ctx:is_dir(ChildCtx),
  +    case IsDir of
  +        true ->
  +            {DirLocation, _} = file_ctx:get_dir_location_doc(ChildCtx2),
  +            case dir_location:is_storage_file_created(DirLocation) of
  +                true ->
  +                    ok;
  +                _ ->
  +                    ets:delete(TableName, LinkName)
  +            end;
  +        _ ->
  +            {FileLocation, _} = file_ctx:get_local_file_location_doc(ChildCtx2, false),
  +            case file_location:is_storage_file_created(FileLocation) of
  +                true ->
  +                    ok;
  +                _ ->
  +                    ets:delete(TableName, LinkName)
  +            end
  +    end,
  +    filter_children_in_db(ets:next(TableName, LinkName), FileCtx, UserCtx, TableName).
   
   %%-------------------------------------------------------------------
   %% @private
  
positive.code: %% and save their names in ets TableName.
  %% @end
  %%-------------------------------------------------------------------
  -spec save_db_children_names(atom(), file_ctx:ctx()) -> term().
  save_db_children_names(TableName, FileCtx) ->
      FileUuid = file_ctx:get_uuid_const(FileCtx),
      file_meta:foreach_child({uuid, FileUuid}, fun
          (LinkName, _LinkTarget, AccIn) ->
              case file_meta:is_hidden(LinkName) of
  
negative.code: -spec maybe_delete_imported_dir_and_update_counters(file_ctx:ctx(),
      od_space:id(), storage:id()) -> ok.
  maybe_delete_imported_dir_and_update_counters(FileCtx, SpaceId, StorageId) ->
      delete_imported_dir(FileCtx, SpaceId, StorageId),
      {StorageFileId, _} = file_ctx:get_storage_file_id(FileCtx),
      storage_sync_utils:log_deletion(StorageFileId, SpaceId),
      storage_sync_monitoring:mark_deleted_file(SpaceId, StorageId),
      ok.
  
  %%-------------------------------------------------------------------
  %% @doc
  %% This function deletes regular file and update syn counters.
  %% @end
  %%-------------------------------------------------------------------
  -spec maybe_delete_imported_regular_file_and_update_counters(file_ctx:ctx(),
      od_space:id(), storage:id()) -> ok.
  maybe_delete_imported_regular_file_and_update_counters(FileCtx, SpaceId, StorageId) ->
      delete_imported_file(FileCtx),
      {StorageFileId, _} = file_ctx:get_storage_file_id(FileCtx),
      storage_sync_utils:log_deletion(StorageFileId, SpaceId),
      storage_sync_monitoring:mark_deleted_file(SpaceId, StorageId),
      ok.
  
  
  