Skip to content

Commit

Permalink
fix(files): better conversion error messages
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv committed Jan 22, 2025
1 parent a028fe6 commit 54bf0fb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/files/src/actions/convertUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export const convertFiles = async function(fileIds: number[], targetMimeType: st
try {
const results = await Promise.allSettled(conversions)
const failed = results.filter(result => result.status === 'rejected')
if (failed.length) {
if (failed.length > 0) {
const messages = failed.map(result => result.reason?.response?.data?.ocs?.meta?.message) as string[]
logger.error('Failed to convert files', { fileIds, targetMimeType, error })
logger.error('Failed to convert files', { fileIds, targetMimeType, messages })

// If all failed files have the same error message, show it
if (new Set(messages).size === 1) {
Expand All @@ -47,7 +47,7 @@ export const convertFiles = async function(fileIds: number[], targetMimeType: st
}

if (failed.length === fileIds.length) {
showError(t('files', 'Failed to convert files'))
showError(t('files', 'All files failed to be converted'))
return
}

Expand All @@ -64,7 +64,10 @@ export const convertFiles = async function(fileIds: number[], targetMimeType: st
return
}

// We already check above when all files failed
// if we're here, we have a mix of failed and successful files
showError(t('files', '{count} files could not be converted', { count: failed.length }))
showSuccess(t('files', '{count} files successfully converted', { count: fileIds.length - failed.length }))
return
}

Expand Down

0 comments on commit 54bf0fb

Please sign in to comment.