diff --git a/ReactNativeClient/lib/models/Setting.js b/ReactNativeClient/lib/models/Setting.js index 3c2f298ce..7c8bc60bf 100644 --- a/ReactNativeClient/lib/models/Setting.js +++ b/ReactNativeClient/lib/models/Setting.js @@ -100,7 +100,7 @@ class Setting extends BaseModel { 'encryption.activeMasterKeyId': { value: '', type: Setting.TYPE_STRING, public: false }, 'encryption.passwordCache': { value: {}, type: Setting.TYPE_OBJECT, public: false }, 'style.zoom': {value: "100", type: Setting.TYPE_INT, public: true, appTypes: ['desktop'], label: () => _('Global zoom percentage'), minimum: "50", maximum: "500", step: "10"}, - 'style.editor.fontFamily': {value: "", type: Setting.TYPE_STRING, public: true, appTypes: ['desktop'], label: () => _('Editor font family'), description: () => _('The font name will not be checked. If incorrect or empty, it will default to a generic monospace font.')}, + 'style.editor.fontFamily': {value: "", type: Setting.TYPE_STRING, public: true, appTypes: ['desktop'], label: () => _('Editor font family'), description: () => _('This must be *monospace* font or it will not work properly. If the font is incorrect or empty, it will default to a generic monospace font.')}, 'autoUpdateEnabled': { value: true, type: Setting.TYPE_BOOL, public: true, appTypes: ['desktop'], label: () => _('Automatically update the application') }, 'sync.interval': { value: 300, type: Setting.TYPE_INT, isEnum: true, public: true, label: () => _('Synchronisation interval'), options: () => { return { diff --git a/ReactNativeClient/lib/shim-init-node.js b/ReactNativeClient/lib/shim-init-node.js index 042712f06..12e08238d 100644 --- a/ReactNativeClient/lib/shim-init-node.js +++ b/ReactNativeClient/lib/shim-init-node.js @@ -184,7 +184,7 @@ function shimInit() { const requestOptions = { protocol: url.protocol, - host: url.host, + host: url.hostname, port: url.port, method: method, path: url.path + (url.query ? '?' + url.query : ''), @@ -193,9 +193,29 @@ function shimInit() { const doFetchOperation = async () => { return new Promise((resolve, reject) => { + let file = null; + + const cleanUpOnError = (error) => { + // We ignore any unlink error as we only want to report on the main error + fs.unlink(filePath).catch(() => {}).then(() => { + if (file) { + file.close(() => { + file = null; + reject(error); + }); + } else { + reject(error); + } + }); + } + try { // Note: relative paths aren't supported - const file = fs.createWriteStream(filePath); + file = fs.createWriteStream(filePath); + + file.on('error', function(error) { + cleanUpOnError(error); + }); const request = http.request(requestOptions, function(response) { response.pipe(file); @@ -208,14 +228,12 @@ function shimInit() { }) request.on('error', function(error) { - fs.unlink(filePath); - reject(error); + cleanUpOnError(error); }); request.end(); - } catch(error) { - fs.unlink(filePath); - reject(error); + } catch (error) { + cleanUpOnError(error); } }); };