Skip to content

Commit

Permalink
Temp fix to handle cache file corruption. (#645)
Browse files Browse the repository at this point in the history
* Temp fix to handle cache file corruption.

* Handle corrupted Utilization-Time to avoid dashboard breakage.
  • Loading branch information
Dileep17 authored Feb 14, 2023
1 parent 3258e48 commit 17ecb94
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/device-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,17 @@ function getStorage() {
* @returns number
*/
export async function getUtilizationTime(udid: string) {
const value = await getStorage().getItem(udid);
if (value !== undefined) {
return value;
try {
const value = await getStorage().getItem(udid);
if (value !== undefined && value && !isNaN(value)) {
return value;
} else {
throw `Custom Exception: Utilizaiton time in cache is corrupted. Value = '${value}'.`;
}
} catch (err) {
logger.error(`Failed to fetch Utilization Time \n ${err}`);
}

return 0;
}

Expand Down

0 comments on commit 17ecb94

Please sign in to comment.