mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-27 08:21:03 +02:00
* Speed up Linux Sync with KeepAlive Client * Tidying up * eslint * Fix Breaking of building mobile client * Refactor to make building on android possible * Coding Convention * Update shim-init-node.js Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
parent
721dd17686
commit
1d284a3528
@ -6,6 +6,7 @@ const URL = require('url-parse');
|
||||
const { rtrimSlashes } = require('lib/path-utils.js');
|
||||
const base64 = require('base-64');
|
||||
|
||||
|
||||
// Note that the d: namespace (the DAV namespace) is specific to Nextcloud. The RFC for example uses "D:" however
|
||||
// we make all the tags and attributes lowercase so we handle both the Nextcloud style and RFC. Hopefully other
|
||||
// implementations use the same namespaces. If not, extra processing can be done in `nameProcessor`, for
|
||||
@ -31,6 +32,7 @@ class WebDavApi {
|
||||
options.headers = Object.assign({}, options.headers);
|
||||
if (options.headers['Authorization']) options.headers['Authorization'] = '********';
|
||||
delete options.method;
|
||||
delete options.agent;
|
||||
output.push(JSON.stringify(options));
|
||||
return output.join(' ');
|
||||
};
|
||||
@ -359,9 +361,11 @@ class WebDavApi {
|
||||
fetchOptions.method = method;
|
||||
if (options.path) fetchOptions.path = options.path;
|
||||
if (body) fetchOptions.body = body;
|
||||
|
||||
const url = `${this.baseUrl()}/${path}`;
|
||||
|
||||
if (shim.httpAgent(url)) fetchOptions.agent = shim.httpAgent(url);
|
||||
|
||||
|
||||
let response = null;
|
||||
|
||||
// console.info('WebDAV Call', `${method} ${url}`, headers, options);
|
||||
|
@ -9,6 +9,8 @@ const Note = require('lib/models/Note.js');
|
||||
const Resource = require('lib/models/Resource.js');
|
||||
const urlValidator = require('valid-url');
|
||||
const { _ } = require('lib/locale.js');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
|
||||
function shimInit() {
|
||||
shim.fsDriver = () => {
|
||||
@ -363,6 +365,24 @@ function shimInit() {
|
||||
return bridge().openExternal(url);
|
||||
};
|
||||
|
||||
shim.httpAgent_ = null;
|
||||
|
||||
shim.httpAgent = url => {
|
||||
if (shim.isLinux() && !shim.httpAgent) {
|
||||
var AgentSettings = {
|
||||
keepAlive: true,
|
||||
maxSockets: 1,
|
||||
keepAliveMsecs: 5000,
|
||||
};
|
||||
if (url.startsWith('https')) {
|
||||
shim.httpAgent_ = new https.Agent(AgentSettings);
|
||||
} else {
|
||||
shim.httpAgent_ = new http.Agent(AgentSettings);
|
||||
}
|
||||
}
|
||||
return shim.httpAgent_;
|
||||
};
|
||||
|
||||
shim.openOrCreateFile = (filepath, defaultContents) => {
|
||||
// If the file doesn't exist, create it
|
||||
if (!fs.existsSync(filepath)) {
|
||||
|
@ -132,6 +132,10 @@ function shimInit() {
|
||||
Linking.openURL(url);
|
||||
};
|
||||
|
||||
shim.httpAgent = () => {
|
||||
return null;
|
||||
};
|
||||
|
||||
shim.waitForFrame = () => {
|
||||
return new Promise(function(resolve) {
|
||||
requestAnimationFrame(function() {
|
||||
|
@ -190,6 +190,9 @@ shim.Buffer = null;
|
||||
shim.openUrl = () => {
|
||||
throw new Error('Not implemented');
|
||||
};
|
||||
shim.httpAgent = () => {
|
||||
throw new Error('Not implemented');
|
||||
};
|
||||
shim.openOrCreateFile = () => {
|
||||
throw new Error('Not implemented');
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user