From 3d68688f336ef551e9461fc1987ae6d087fe4107 Mon Sep 17 00:00:00 2001 From: Jonas Hermsmeier Date: Fri, 24 Mar 2017 16:58:13 +0100 Subject: [PATCH] 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 --- lib/image-stream/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/image-stream/index.js b/lib/image-stream/index.js index 04c80010..a71c1b2c 100644 --- a/lib/image-stream/index.js +++ b/lib/image-stream/index.js @@ -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); }); };