Skip to content

isResourceLockedForPathByAncestor

Checks whether the note at the given path is currently locked directly OR is covered by a subtree-locked ancestor folder.

Unlike isResourceLockedForPath, which only reports an exact-path lock, this also reports a path that lies under a folder locked in subtree mode. Use it to detect that a rename/move is happening inside a foreign plugin’s in-flight locked transaction (which locks the affected folder subtree), so that a bystander (e.g. the rename/delete handler) can stay out of the way and let the transaction’s owner keep its own links consistent.

Import:

import { isResourceLockedForPathByAncestor } from 'obsidian-dev-utils/obsidian/resource-lock';

Signature:

function isResourceLockedForPathByAncestor(app: App, pathOrFile: PathOrFile): boolean

Parameters:

ParameterTypeDescription
appAppThe Obsidian app instance.
pathOrFilePathOrFileThe path or file of the note to check.

Returns: booleantrue if the path is itself locked or lies under a subtree-locked ancestor folder.