1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Desktop: Fixes #1023: Speed up WebDAV and Nextcloud Sync on Linux (#2577)

* 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:
WisdomCode
2020-02-27 00:14:40 +00:00
committed by GitHub
parent 721dd17686
commit 1d284a3528
4 changed files with 32 additions and 1 deletions

View File

@ -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)) {