fix(image-stream): destroy unused image streams (#1211)

When fetching metadata, a stream is opened, but never consumed.
This destroys the stream when retrieving metadata to avoid
dangling open file descriptors and such.

Change-Type: patch
Changelog-Entry: Fix unmounting freezing in macOS.
Fixes: https://github.com/resin-io/etcher/issues/985
This commit is contained in:
Jonas Hermsmeier 2017-03-24 16:58:13 +01:00 committed by Juan Cruz Viotti
parent 198ddb7433
commit 3d68688f33

View File

@ -108,6 +108,11 @@ exports.getFromFilePath = (file) => {
*/
exports.getImageMetadata = (file) => {
return exports.getFromFilePath(file).then((image) => {
// Since we're not consuming this stream,
// destroy() it, to avoid dangling open file descriptors etc.
image.stream.destroy();
return _.omitBy(image, isStream);
});
};