Windows: mark downloads as "from the internet"

This commit is contained in:
Evan Hahn 2020-09-11 16:17:07 -05:00 committed by Josh Perez
parent 50378ed9bc
commit 6d2e994f9f
5 changed files with 152 additions and 0 deletions

View file

@ -12,6 +12,10 @@ const normalizePath = require('normalize-path');
const sanitizeFilename = require('sanitize-filename');
const getGuid = require('uuid/v4');
const { isPathInside } = require('../ts/util/isPathInside');
const { isWindows } = require('../ts/OS');
const {
writeWindowsZoneIdentifier,
} = require('../ts/util/windowsZoneIdentifier');
let xattr;
try {
@ -229,6 +233,13 @@ async function writeWithAttributes(target, data) {
const attrValue = `${type};${timestamp};${appName};${guid}`;
await xattr.set(target, 'com.apple.quarantine', attrValue);
} else if (isWindows()) {
// This operation may fail (see the function's comments), which is not a show-stopper.
try {
await writeWindowsZoneIdentifier(target);
} catch (err) {
console.warn('Failed to write Windows Zone.Identifier file; continuing');
}
}
}