mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-27 08:21:03 +02:00
Fixed bad connection handling in synchronizer
This commit is contained in:
parent
dc4eb35fca
commit
fdeb797750
@ -1,4 +1,3 @@
|
||||
const fetch = require('node-fetch');
|
||||
const tcpPortUsed = require('tcp-port-used');
|
||||
const http = require("http");
|
||||
const urlParser = require("url");
|
||||
|
@ -5,6 +5,7 @@ import { Log } from 'lib/log.js'
|
||||
import { reg } from 'lib/registry.js'
|
||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { time } from 'lib/time-utils'
|
||||
import { Logger } from 'lib/logger.js';
|
||||
|
||||
class LogScreenComponent extends React.Component {
|
||||
|
||||
@ -35,9 +36,18 @@ class LogScreenComponent extends React.Component {
|
||||
|
||||
render() {
|
||||
let renderRow = (item) => {
|
||||
let color = 'black';
|
||||
if (item.level == Logger.LEVEL_WARN) color = '#9A5B00';
|
||||
if (item.level == Logger.LEVEL_ERROR) color = 'red';
|
||||
|
||||
let style = {
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 10,
|
||||
color: color,
|
||||
};
|
||||
return (
|
||||
<View style={{flexDirection: 'row', paddingLeft: 1, paddingRight: 1, paddingTop:0, paddingBottom:0 }}>
|
||||
<Text style={{fontFamily: 'monospace', fontSize: 10}}>{time.unixMsToIsoSec(item.timestamp) + ': ' + item.message}</Text>
|
||||
<Text style={style}>{time.unixMsToIsoSec(item.timestamp) + ': ' + item.message}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
@ -100,9 +100,9 @@ class Logger {
|
||||
let target = this.targets_[i];
|
||||
if (target.type == 'console') {
|
||||
let fn = 'debug';
|
||||
if (level = Logger.LEVEL_ERROR) fn = 'error';
|
||||
if (level = Logger.LEVEL_WARN) fn = 'warn';
|
||||
if (level = Logger.LEVEL_INFO) fn = 'info';
|
||||
if (level == Logger.LEVEL_ERROR) fn = 'error';
|
||||
if (level == Logger.LEVEL_WARN) fn = 'warn';
|
||||
if (level == Logger.LEVEL_INFO) fn = 'info';
|
||||
console[fn](line + this.objectsToString(...object));
|
||||
} else if (target.type == 'file') {
|
||||
let serializedObject = this.objectsToString(...object);
|
||||
|
@ -174,7 +174,7 @@ class OneDriveApi {
|
||||
this.logger().info('Token expired: refreshing...');
|
||||
await this.refreshAccessToken();
|
||||
continue;
|
||||
} else if (error && ((error.error && error.error.code == 'generalException') || (error.code == 'generalException'))) {
|
||||
} else if (error && ((error.error && error.error.code == 'generalException') || error.code == 'generalException' || error.code == 'EAGAIN')) {
|
||||
// Rare error (one Google hit) - I guess the request can be repeated
|
||||
// { error:
|
||||
// { code: 'generalException',
|
||||
@ -182,11 +182,7 @@ class OneDriveApi {
|
||||
// innerError:
|
||||
// { 'request-id': 'b4310552-c18a-45b1-bde1-68e2c2345eef',
|
||||
// date: '2017-06-29T00:15:50' } } }
|
||||
this.logger().info('Got error below - retrying...');
|
||||
this.logger().info(error);
|
||||
await time.msleep(1000 * i);
|
||||
continue;
|
||||
} else if (error.code == 'EAGAIN') {
|
||||
|
||||
// { FetchError: request to https://graph.microsoft.com/v1.0/drive/root:/Apps/Joplin/.sync/7ee5dc04afcb414aa7c684bfc1edba8b.md_1499352102856 failed, reason: connect EAGAIN 65.52.64.250:443 - Local (0.0.0.0:54374)
|
||||
// name: 'FetchError',
|
||||
// message: 'request to https://graph.microsoft.com/v1.0/drive/root:/Apps/Joplin/.sync/7ee5dc04afcb414aa7c684bfc1edba8b.md_1499352102856 failed, reason: connect EAGAIN 65.52.64.250:443 - Local (0.0.0.0:54374)',
|
||||
|
@ -74,6 +74,15 @@ class Synchronizer {
|
||||
this.logger().info('Total folders: ' + folderCount);
|
||||
this.logger().info('Total notes: ' + noteCount);
|
||||
this.logger().info('Total resources: ' + resourceCount);
|
||||
|
||||
if (report.errors.length) {
|
||||
this.logger().warn('There was some errors:');
|
||||
for (let i = 0; i < report.errors.length; i++) {
|
||||
let e = report.errors[i];
|
||||
let msg = e && e.message ? e.message : JSON.stringify(e);
|
||||
this.logger().warn(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
randomFailure(options, name) {
|
||||
@ -136,6 +145,7 @@ class Synchronizer {
|
||||
noteConflict: 0,
|
||||
|
||||
state: this.state(),
|
||||
errors: [],
|
||||
};
|
||||
|
||||
try {
|
||||
@ -397,8 +407,8 @@ class Synchronizer {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
report.errors.push(error);
|
||||
this.logger().error(error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (this.cancelling()) {
|
||||
|
@ -245,7 +245,7 @@ async function initialize(dispatch) {
|
||||
path: localFilePath
|
||||
}).fetch(method, url, headers);
|
||||
|
||||
// Returns an object that roughtly compatible with a standard Response object
|
||||
// Returns an object that's roughtly compatible with a standard Response object
|
||||
let output = {
|
||||
ok: response.respInfo.status < 400,
|
||||
path: response.data,
|
||||
@ -293,12 +293,12 @@ async function initialize(dispatch) {
|
||||
} else {
|
||||
await db.open({ name: 'joplin-53.sqlite' })
|
||||
|
||||
// await db.exec('DELETE FROM notes');
|
||||
// await db.exec('DELETE FROM folders');
|
||||
// await db.exec('DELETE FROM tags');
|
||||
// await db.exec('DELETE FROM note_tags');
|
||||
// await db.exec('DELETE FROM resources');
|
||||
// await db.exec('DELETE FROM deleted_items');
|
||||
await db.exec('DELETE FROM notes');
|
||||
await db.exec('DELETE FROM folders');
|
||||
await db.exec('DELETE FROM tags');
|
||||
await db.exec('DELETE FROM note_tags');
|
||||
await db.exec('DELETE FROM resources');
|
||||
await db.exec('DELETE FROM deleted_items');
|
||||
}
|
||||
|
||||
reg.logger().info('Database is ready.');
|
||||
|
Loading…
Reference in New Issue
Block a user