Browse Source

fix(nc-gui): fix duplicate filename suffix issue

pull/7695/head
Ramesh Mane 10 months ago
parent
commit
784e5c17db
  1. 5
      packages/nc-gui/utils/fileUtils.ts

5
packages/nc-gui/utils/fileUtils.ts

@ -87,8 +87,11 @@ export function populateUniqueFileName(fn: string, attachments: any[], mimeType:
}
let c = 1
let originalFn = fn
while (attachments.some((att) => att?.title === fn || att?.fileName === fn)) {
fn = fn.replace(/(.+?)(\.[^.]+)$/, `$1(${c++})$2`)
const match = fn.match(/^(.+?)(\(\d+\))?(\.[^.]+)$/)
fn = match ? `${match[1]}(${c++})${match[3]}` : `${originalFn}(${c++})`
}
return fn
}

Loading…
Cancel
Save