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
This commit is contained in:
Jonas Hermsmeier 2017-11-23 14:42:11 +01:00 committed by GitHub
parent 4e891151f4
commit 69c3d61c28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)) {