Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
rangesCallback: (ranges: Range[]) => {
if (approximateSize) {
extensionPoint.progressCallback({
fullyLoadedFractionRanges: ranges.map(({ start, end }) => ({
start: Math.max(0, start / approximateSize),
end: Math.min(1, end / approximateSize),
})),
});
}
},
});
await remoteReader.open(); // Important that we call this first, because it might throw an error if the file can't be read.
approximateSize = remoteReader.size() * 0.99; // Chop off the last percentage or so for the indexes.
this._bag = new Bag(new BagReader(remoteReader));
await this._bag.open();
} else {
this._bag = await open(bagPath.file);
extensionPoint.progressCallback({ fullyLoadedFractionRanges: [{ start: 0, end: 1 }] });
}
const { startTime, endTime } = this._bag;
const connections = ((Object.values(this._bag.connections): any): Connection[]);
if (!startTime || !endTime || !connections.length) {
// This will abort video generation:
reportError("Invalid bag", "Bag is empty or corrupt.", "user");
return new Promise(() => {}); // Just never finish initializing.
}
this._connectionsByTopic = keyBy(connections, "topic");
return {