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

Function uniqueFilename

apps/desktop/src/main/vault.ts:2827–2841  ·  view source on GitHub ↗
(dir: string, filename: string)

Source from the content-addressed store, hash-verified

2825}
2826
2827async function uniqueFilename(dir: string, filename: string): Promise<string> {
2828 const ext = path.extname(filename)
2829 const base = path.basename(filename, ext)
2830 let candidate = filename
2831 let n = 2
2832 while (true) {
2833 try {
2834 await fs.access(path.join(dir, candidate))
2835 candidate = `${base} ${n}${ext}`
2836 n += 1
2837 } catch {
2838 return candidate
2839 }
2840 }
2841}
2842
2843function classifyImportedAsset(filename: string): ImportedAssetKind {
2844 const ext = path.extname(filename).toLowerCase()

Callers 5

moveAssetFunction · 0.85
duplicateAssetFunction · 0.85
restoreDeletedAssetFunction · 0.85
importFilesFunction · 0.85
importPastedImageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected