feat: block upload file replace other system file

This commit is contained in:
Methapon2001 2024-01-12 13:53:15 +07:00
parent fb70e5174a
commit b100da112d
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
4 changed files with 12 additions and 19 deletions

View file

@ -22,12 +22,12 @@ const fileFormData = ref<{
}>({})
const fileFormType = ref<'edit' | 'create'>('create')
const fileFormError = ref<{
fileExistMetadata?: boolean
externalFileExist?: boolean
fileExist?: boolean
fileName2Long?: boolean
}>({})
const fileExistNotification = ref<boolean>(false)
const errorState = ref<'fileExist' | 'fileExistMetadata'>('fileExist')
const errorState = ref<'fileExist' | 'externalFileExist'>('fileExist')
const fileFormComponent = ref<InstanceType<typeof FileForm>>()
const fileNameLabel = ref<string>()
@ -114,7 +114,7 @@ async function submitFileForm(
if (fileInfo?.metadata && Object.keys(fileInfo.metadata).length > 0) {
fileExistNotification.value = true
errorState.value = 'fileExistMetadata'
errorState.value = 'externalFileExist'
return
}
@ -178,7 +178,7 @@ async function submitFileForm(
@reset="() => (fileFormError = {})"
@filechange="
(name: string) => {
fileFormError.fileExistMetadata = checkFileExistMetadata(name)
fileFormError.externalFileExist = checkFileExistMetadata(name)
;(fileFormError.fileExist = checkFileExist(name, fileNameLabel)),
(fileFormError.fileName2Long = checkFileName2Long(
name,