mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-30 10:36:35 +02:00
All: Fixes #491: Handle non-standard ports and better handling of fetchBlob errors
This commit is contained in:
parent
43bab3c1bd
commit
04724c58d1
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user