MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / assertAssetFile

Function assertAssetFile

apps/desktop/src/main/vault.ts:2865–2878  ·  view source on GitHub ↗
(root: string, rel: string)

Source from the content-addressed store, hash-verified

2863}
2864
2865async function assertAssetFile(root: string, rel: string): Promise<{ rel: string; abs: string }> {
2866 const normalized = normalizeVaultRelativePath(rel)
2867 if (!normalized) throw new Error('Asset path is required.')
2868 if (normalized.split('/').includes(INTERNAL_VAULT_DIR)) {
2869 throw new Error('Cannot modify internal ZenNotes files.')
2870 }
2871 if (path.extname(normalized).toLowerCase() === '.md') {
2872 throw new Error('Use note actions to modify markdown notes.')
2873 }
2874 const abs = resolveSafe(root, normalized)
2875 const info = await fs.stat(abs)
2876 if (!info.isFile()) throw new Error('Asset path is not a file.')
2877 return { rel: normalized, abs }
2878}
2879
2880function cleanAssetFilename(name: string): string {
2881 const raw = name.trim()

Callers 4

renameAssetFunction · 0.85
moveAssetFunction · 0.85
duplicateAssetFunction · 0.85
deleteAssetFunction · 0.85

Calls 2

resolveSafeFunction · 0.70

Tested by

no test coverage detected