diff --git a/src/bundles/files/actions.js b/src/bundles/files/actions.js index d3f349a33..e79ffb900 100644 --- a/src/bundles/files/actions.js +++ b/src/bundles/files/actions.js @@ -101,20 +101,26 @@ const stat = async (ipfs, cidOrPath) => { } else { stats = await ipfs.files.stat(path) } - return { path, ...stats } - } catch (e) { - // Discard error and mark DAG as 'unknown' to unblock listing other pins. - // Clicking on 'unknown' entry will open it in Inspector. - // No information is lost: if there is an error related - // to specified hashOrPath user will read it in Inspector. - const [, , cid] = path.split('/') - return { - path: hashOrPath, - cid: CID.asCID(cid) ?? CID.parse(cid), - type: 'unknown', - cumulativeSize: 0, - size: 0 + + if (stats.type === 'error') { + throw Object.assign(new Error(stats.message || 'Failed to get file stats'), { + code: 'ERR_FILES_STAT_FAILED' + }) } + + return { path, ...stats } + } catch (error) { + const e = error instanceof Error ? error : new Error('Unknown error') + throw Object.assign(e, { + code: 'ERR_FILES_STAT_FAILED', + fallback: { + path: hashOrPath, + cid: CID.asCID(path.split('/')[2]) ?? CID.parse(path.split('/')[2]), + type: 'unknown', + cumulativeSize: 0, + size: 0 + } + }) } } diff --git a/src/bundles/notify.js b/src/bundles/notify.js index 7bd7ca256..f0ba78807 100644 --- a/src/bundles/notify.js +++ b/src/bundles/notify.js @@ -24,6 +24,17 @@ const notify = { return { ...state, show: false } } + if (action.type === 'FILES_STAT_FAILED') { + return { + ...state, + show: true, + error: true, + eventId: 'FILES_EVENT_FAILED', + code: action.payload.error.code, + msgArgs: { message: action.payload.error.message } + } + } + if (action.type === 'STATS_FETCH_FAILED') { return { ...state,