🐛 Unknown file for file roots with no format/extension (#845)

This commit is contained in:
Montassar Ghanmy
2025-03-10 09:50:43 +01:00
committed by GitHub
parent 4c0f85469c
commit fe6c13e067
4 changed files with 11 additions and 3 deletions
@@ -33,7 +33,7 @@ const PendingRootRow = ({
const uploadedFilesSize = root.uploadedSize; const uploadedFilesSize = root.uploadedSize;
const uploadProgress = Math.floor((uploadedFilesSize / root.size) * 100); const uploadProgress = Math.floor((uploadedFilesSize / root.size) * 100);
const isUploadCompleted = root.status === 'completed'; const isUploadCompleted = root.status === 'completed';
const isFileRoot = rootKey.includes('.'); const isFileRoot = root.isUnknownFormat || rootKey.includes('.');
const fileType = isFileRoot ? rootKey.split('.').pop() : ''; const fileType = isFileRoot ? rootKey.split('.').pop() : '';
// Callback function to open the folder after the upload is completed // Callback function to open the folder after the upload is completed
@@ -63,7 +63,7 @@ class FileUploadService {
async _waitWhilePaused(id?: string) { async _waitWhilePaused(id?: string) {
logger.debug('===== _waitWhilePaused ======'); logger.debug('===== _waitWhilePaused ======');
logger.debug('rootStates: ', this.rootStates); logger.debug('rootStates: ', this.rootStates);
logger.debug('status: ', this.uploadStatus) logger.debug('status: ', this.uploadStatus);
while (this.uploadStatus === UploadStateEnum.Paused || (id && this.rootStates.paused[id])) { while (this.uploadStatus === UploadStateEnum.Paused || (id && this.rootStates.paused[id])) {
if (this.uploadStatus === UploadStateEnum.Cancelled || (id && this.rootStates.cancelled[id])) if (this.uploadStatus === UploadStateEnum.Cancelled || (id && this.rootStates.cancelled[id]))
return; return;
@@ -105,6 +105,11 @@ class FileUploadService {
this.rootStates.failed[key] = true; this.rootStates.failed[key] = true;
} }
// Check if the root is a file with unknow format
const isUnknownFormat =
this.groupedPendingFiles[key]?.length === 1 &&
this.groupedPendingFiles[key][0].originalFile?.name === key;
// Determine the upload status based on failed, cancelled, paused, completed, or uploading states // Determine the upload status based on failed, cancelled, paused, completed, or uploading states
const status = this.rootStates.failed[key] const status = this.rootStates.failed[key]
? 'failed' ? 'failed'
@@ -127,6 +132,7 @@ class FileUploadService {
size: this.rootSizes[key], size: this.rootSizes[key],
uploadedSize, uploadedSize,
status, status,
isUnknownFormat,
}; };
return acc; return acc;
@@ -308,7 +314,7 @@ class FileUploadService {
): Promise<PendingFileType[]> { ): Promise<PendingFileType[]> {
logger.debug('===== upload ====='); logger.debug('===== upload =====');
logger.debug('uploadStatus: ', this.uploadStatus); logger.debug('uploadStatus: ', this.uploadStatus);
// reset the upload status when creating a new document // reset the upload status when creating a new document
if (fileList.length === 1 && fileList[0].root === fileList[0].file.name) { if (fileList.length === 1 && fileList[0].root === fileList[0].file.name) {
if (this.uploadStatus === UploadStateEnum.Paused) { if (this.uploadStatus === UploadStateEnum.Paused) {
@@ -9,6 +9,7 @@ export const RootPendingFilesListState = atom<
uploadedSize: number; uploadedSize: number;
status: string; status: string;
items: PendingFileRecoilType[]; items: PendingFileRecoilType[];
isUnknownFormat: boolean;
}; };
} }
| undefined | undefined
@@ -94,6 +94,7 @@ export type UploadRootType = {
uploadedSize: number; uploadedSize: number;
status: string; status: string;
items: PendingFileRecoilType[]; items: PendingFileRecoilType[];
isUnknownFormat: boolean;
}; };
export type UploadRootListType = { export type UploadRootListType = {