anchor.diff:      ok | logical_file_manager:error_reply().
   -check_permissions([{?delete_subcontainer, {parent, 2}}]).
   rename_dir(CTX, SourceEntry, CanonicalTargetPath, LogicalTargetPath) ->
  -    case check_dir_preconditions(CTX, SourceEntry, CanonicalTargetPath, LogicalTargetPath) of
  +    case check_dir_preconditions(CTX, SourceEntry, LogicalTargetPath) of
           ok ->
               rename_select(CTX, SourceEntry, CanonicalTargetPath, LogicalTargetPath, ?DIRECTORY_TYPE);
           Error ->
  
positive.code: %%--------------------------------------------------------------------
  -spec moving_into_itself(SessId :: session:id(),
      SourceEntry :: fslogic_worker:file(),
      CanonicalTargetPath :: file_meta:path()) -> boolean().
  moving_into_itself(SessId, SourceEntry, CanonicalTargetPath) ->
      {ok, SourcePath} = fslogic_path:gen_path(SourceEntry, SessId),
      SourceTokens = fslogic_path:split(SourcePath),
      TargetTokens = fslogic_path:split(CanonicalTargetPath),
      lists:prefix(SourceTokens, TargetTokens).
  
  %%--------------------------------------------------------------------
  
negative.code: %% @doc Checks preconditions for renaming directory.
  %%--------------------------------------------------------------------
  -spec check_dir_preconditions(fslogic_worker:ctx(), fslogic_worker:file(),
      file_meta:path()) -> ok | logical_file_manager:error_reply().
  check_dir_preconditions(#fslogic_ctx{session_id = SessId}, SourceEntry, LogicalTargetPath) ->
      case moving_into_itself(SessId, SourceEntry, LogicalTargetPath) of
          true ->
              {error, ?EINVAL};
          false ->
  