You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
All: Fixes #491: Handle non-standard ports and better handling of fetchBlob errors
This commit is contained in:
@@ -100,7 +100,7 @@ class Setting extends BaseModel {
|
|||||||
'encryption.activeMasterKeyId': { value: '', type: Setting.TYPE_STRING, public: false },
|
'encryption.activeMasterKeyId': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||||
'encryption.passwordCache': { value: {}, type: Setting.TYPE_OBJECT, 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.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') },
|
'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: () => {
|
'sync.interval': { value: 300, type: Setting.TYPE_INT, isEnum: true, public: true, label: () => _('Synchronisation interval'), options: () => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ function shimInit() {
|
|||||||
|
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
protocol: url.protocol,
|
protocol: url.protocol,
|
||||||
host: url.host,
|
host: url.hostname,
|
||||||
port: url.port,
|
port: url.port,
|
||||||
method: method,
|
method: method,
|
||||||
path: url.path + (url.query ? '?' + url.query : ''),
|
path: url.path + (url.query ? '?' + url.query : ''),
|
||||||
@@ -193,9 +193,29 @@ function shimInit() {
|
|||||||
|
|
||||||
const doFetchOperation = async () => {
|
const doFetchOperation = async () => {
|
||||||
return new Promise((resolve, reject) => {
|
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 {
|
try {
|
||||||
// Note: relative paths aren't supported
|
// 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) {
|
const request = http.request(requestOptions, function(response) {
|
||||||
response.pipe(file);
|
response.pipe(file);
|
||||||
@@ -208,14 +228,12 @@ function shimInit() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
request.on('error', function(error) {
|
request.on('error', function(error) {
|
||||||
fs.unlink(filePath);
|
cleanUpOnError(error);
|
||||||
reject(error);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
request.end();
|
request.end();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
fs.unlink(filePath);
|
cleanUpOnError(error);
|
||||||
reject(error);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user