mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-04 02:33:43 +00:00
fixes
This commit is contained in:
parent
6b2c927828
commit
4c581349bd
2 changed files with 18 additions and 15 deletions
|
|
@ -252,7 +252,8 @@ async def upload_file_handler(
|
|||
**({'status': 'pending'} if process else {}),
|
||||
},
|
||||
'meta': {
|
||||
'name': name,
|
||||
# Store original filename with path for sync comparison
|
||||
'name': unsanitized_filename,
|
||||
'content_type': (file.content_type if isinstance(file.content_type, str) else None),
|
||||
'size': len(contents),
|
||||
'file_hash': file_hash,
|
||||
|
|
|
|||
|
|
@ -542,7 +542,21 @@
|
|||
const totalToProcess = new_files.length + changed_files.length;
|
||||
let processedCount = 0;
|
||||
|
||||
// Upload new files (no old version to delete)
|
||||
// STEP 1: Delete removed files FIRST
|
||||
// If a file was incorrectly classified as both "new" and "removed" (due to filename
|
||||
// matching issues), deleting first allows the subsequent upload to succeed.
|
||||
if (removed_file_ids.length > 0) {
|
||||
toast.info(
|
||||
$i18n.t('Removing {{count}} deleted files...', {
|
||||
count: removed_file_ids.length
|
||||
})
|
||||
);
|
||||
for (const fileId of removed_file_ids) {
|
||||
await removeFileFromKnowledgeById(localStorage.token, id, fileId);
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 2: Upload new files
|
||||
for (const filePath of new_files) {
|
||||
const fileData = directoryFiles.find((f) => f.path === filePath);
|
||||
if (fileData) {
|
||||
|
|
@ -557,7 +571,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Upload changed files using atomic upload_and_replace endpoint
|
||||
// STEP 3: Upload changed files using atomic upload_and_replace endpoint
|
||||
for (const changedFile of changed_files) {
|
||||
const fileData = directoryFiles.find((f) => f.path === changedFile.file_path);
|
||||
if (fileData) {
|
||||
|
|
@ -577,18 +591,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Delete removed files (files that no longer exist in directory)
|
||||
if (removed_file_ids.length > 0) {
|
||||
toast.info(
|
||||
$i18n.t('Removing {{count}} deleted files...', {
|
||||
count: removed_file_ids.length
|
||||
})
|
||||
);
|
||||
for (const fileId of removed_file_ids) {
|
||||
await removeFileFromKnowledgeById(localStorage.token, id, fileId);
|
||||
}
|
||||
}
|
||||
|
||||
// Show summary
|
||||
toast.success(
|
||||
$i18n.t(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue