Skip to content

Commit

Permalink
fix: try catching icon read errors before stream
Browse files Browse the repository at this point in the history
Current issue with get-launch-apps wasn't fixed by catching errors while
reading the stream so this next attempt catches errors from the call to
start reading.

If the error occurs asynchronously this may not work either.
  • Loading branch information
KernelDeimos committed Dec 23, 2024
1 parent e736e42 commit e56a62c
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/backend/src/services/AppIconService.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class AppIconService extends BaseService {
const dir_app_icons = await this.get_app_icons();
console.log('APP UID', app_uid);
const node = await dir_app_icons.getChild(`${app_uid}-${size}.png`);
if ( ! await node.exists() ) {

const get_fallback_icon = async () => {
// Use database-stored icon as a fallback
app_icon = app_icon ?? await (async () => {
const app = await get_app({ uid: app_uid });
Expand All @@ -100,15 +101,26 @@ class AppIconService extends BaseService {
};
}

const svc_su = this.services.get('su');
const ll_read = new LLRead();
return {
mime: 'image/png',
stream: await ll_read.run({
fsNode: node,
actor: await svc_su.get_system_actor(),
})
};
if ( ! await node.exists() ) {
return await get_fallback_icon();
}

try {
const svc_su = this.services.get('su');
const ll_read = new LLRead();
return {
mime: 'image/png',
stream: await ll_read.run({
fsNode: node,
actor: await svc_su.get_system_actor(),
})
};
} catch (e) {
this.errors.report('AppIconService.get_icon_stream', {
source: e,
});
return await get_fallback_icon();
}
}

/**
Expand Down

0 comments on commit e56a62c

Please sign in to comment.