From 69c3d61c28d0accece56603a141e7ae08e6b845d Mon Sep 17 00:00:00 2001 From: Jonas Hermsmeier Date: Thu, 23 Nov 2017 14:42:11 +0100 Subject: [PATCH] fix(writer): Set flags manually to avoid verifying cache (#1875) We change from using `rs+` to a composition of read/write, exlusive, sync & direct i/o flags, in order to avoid reading stale data from the cache during verification. Change-Type: patch Changelog-Entry: Fix verification step reading from the cache --- lib/cli/writer.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/cli/writer.js b/lib/cli/writer.js index 103c0d43..173d7dcb 100644 --- a/lib/cli/writer.js +++ b/lib/cli/writer.js @@ -75,7 +75,15 @@ exports.writeImage = (imagePath, drive, options, onProgress) => { }).then(() => { return diskpart.clean(drive.device) }).then(() => { - return fs.openAsync(drive.raw, 'rs+') + /* eslint-disable no-bitwise */ + const flags = fs.constants.O_RDWR | + fs.constants.O_EXCL | + fs.constants.O_NONBLOCK | + fs.constants.O_SYNC | + fs.constants.O_DIRECT + /* eslint-enable no-bitwise */ + + return fs.openAsync(drive.raw, flags) }).then((driveFileDescriptor) => { return imageStream.getFromFilePath(imagePath).then((image) => { if (!constraints.isDriveLargeEnough(drive, image)) {