Skip to content

Commit

Permalink
filter for only .ibf files
Browse files Browse the repository at this point in the history
  • Loading branch information
gniezen committed Dec 1, 2020
1 parent e0d4475 commit ae717ef
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/drivers/insulet/insuletDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1764,8 +1764,21 @@ module.exports = (config) => {
mtp.on('ready', async () => {
await mtp.openSession();
const handles = await mtp.getObjectHandles();
const objectHandle = Math.max(...handles);
const fileName = await mtp.getFileName(objectHandle);

handles.sort((a, b) => b - a);
debug('Handles:', handles);

let fileName;
let objectHandle;
for (let i = 0; i < handles.length; i++) {
objectHandle = handles[i];
// eslint-disable-next-line no-await-in-loop
fileName = await mtp.getFileName(objectHandle);
if (_.endsWith(fileName, '.ibf')) {
break;
}
}

bytes = await mtp.getFile(objectHandle, fileName);
buf = bytes.buffer;
await mtp.close();
Expand Down

0 comments on commit ae717ef

Please sign in to comment.