You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-17 23:27:48 +02:00
test
This commit is contained in:
@@ -27,6 +27,8 @@ import MasterKey from './models/MasterKey';
|
||||
const { sprintf } = require('sprintf-js');
|
||||
const { Dirnames } = require('./services/synchronizer/utils/types');
|
||||
|
||||
const logger = Logger.create('Synchronizer');
|
||||
|
||||
interface RemoteItem {
|
||||
id: string;
|
||||
path?: string;
|
||||
@@ -217,9 +219,9 @@ export default class Synchronizer {
|
||||
}
|
||||
|
||||
if (Synchronizer.verboseMode) {
|
||||
this.logger().info(line.join(': '));
|
||||
logger.info(line.join(': '));
|
||||
} else {
|
||||
this.logger().debug(line.join(': '));
|
||||
logger.debug(line.join(': '));
|
||||
}
|
||||
|
||||
if (!this.progressReport_[action]) this.progressReport_[action] = 0;
|
||||
@@ -237,7 +239,7 @@ export default class Synchronizer {
|
||||
}
|
||||
|
||||
async logSyncSummary(report: any) {
|
||||
this.logger().info('Operations completed: ');
|
||||
logger.info('Operations completed: ');
|
||||
for (const n in report) {
|
||||
if (!report.hasOwnProperty(n)) continue;
|
||||
if (n == 'errors') continue;
|
||||
@@ -246,20 +248,20 @@ export default class Synchronizer {
|
||||
if (n == 'state') continue;
|
||||
if (n == 'startTime') continue;
|
||||
if (n == 'completedTime') continue;
|
||||
this.logger().info(`${n}: ${report[n] ? report[n] : '-'}`);
|
||||
logger.info(`${n}: ${report[n] ? report[n] : '-'}`);
|
||||
}
|
||||
const folderCount = await Folder.count();
|
||||
const noteCount = await Note.count();
|
||||
const resourceCount = await Resource.count();
|
||||
this.logger().info(`Total folders: ${folderCount}`);
|
||||
this.logger().info(`Total notes: ${noteCount}`);
|
||||
this.logger().info(`Total resources: ${resourceCount}`);
|
||||
logger.info(`Total folders: ${folderCount}`);
|
||||
logger.info(`Total notes: ${noteCount}`);
|
||||
logger.info(`Total resources: ${resourceCount}`);
|
||||
|
||||
if (Synchronizer.reportHasErrors(report)) {
|
||||
this.logger().warn('There was some errors:');
|
||||
logger.warn('There was some errors:');
|
||||
for (let i = 0; i < report.errors.length; i++) {
|
||||
const e = report.errors[i];
|
||||
this.logger().warn(e);
|
||||
logger.warn(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,8 +296,8 @@ export default class Synchronizer {
|
||||
|
||||
for (const r of lastRequests) {
|
||||
const timestamp = time.unixMsToLocalHms(r.timestamp);
|
||||
this.logger().info(`Req ${timestamp}: ${r.request}`);
|
||||
this.logger().info(`Res ${timestamp}: ${r.response}`);
|
||||
logger.info(`Req ${timestamp}: ${r.request}`);
|
||||
logger.info(`Res ${timestamp}: ${r.response}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,11 +396,11 @@ export default class Synchronizer {
|
||||
// plain text.
|
||||
try {
|
||||
if (this.resourceService()) {
|
||||
this.logger().info('Indexing resources...');
|
||||
logger.info('Indexing resources...');
|
||||
await this.resourceService().indexNoteResources();
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger().error('Error indexing resources:', error);
|
||||
logger.error('Error indexing resources:', error);
|
||||
}
|
||||
|
||||
// Before synchronising make sure all share_id properties are set
|
||||
@@ -416,19 +418,22 @@ export default class Synchronizer {
|
||||
|
||||
try {
|
||||
const remoteInfo = await remoteSyncTargetInfo(this.api());
|
||||
this.logger().info('Sync target info:', remoteInfo);
|
||||
logger.info('Sync target remote info:', remoteInfo);
|
||||
|
||||
if (!remoteInfo.version) {
|
||||
this.logger().info('Sync target is new - setting it up...');
|
||||
logger.info('Sync target is new - setting it up...');
|
||||
await this.migrationHandler().upgrade(Setting.value('syncVersion'));
|
||||
} else {
|
||||
this.logger().info('Sync target is already setup - checking it...');
|
||||
logger.info('Sync target is already setup - checking it...');
|
||||
await this.migrationHandler().checkCanSync(remoteInfo);
|
||||
|
||||
const localInfo = localSyncTargetInfo();
|
||||
|
||||
logger.info('Sync target local info:', localInfo);
|
||||
|
||||
if (!syncTargetInfoEquals(localInfo, remoteInfo)) {
|
||||
const newInfo = mergeSyncTargetInfos(localInfo, remoteInfo);
|
||||
logger.info('Sync target info differs between local and remote - merging infos: ', newInfo);
|
||||
await setRemoteSyncTargetInfo(this.api(), newInfo);
|
||||
setLocalSyncTargetInfo(newInfo);
|
||||
|
||||
@@ -455,7 +460,7 @@ export default class Synchronizer {
|
||||
syncLock = await this.lockHandler().acquireLock(LockType.Sync, this.appType_, this.clientId_);
|
||||
|
||||
this.lockHandler().startAutoLockRefresh(syncLock, (error: any) => {
|
||||
this.logger().warn('Could not refresh lock - cancelling sync. Error was:', error);
|
||||
logger.warn('Could not refresh lock - cancelling sync. Error was:', error);
|
||||
this.syncTargetIsLocked_ = true;
|
||||
void this.cancel();
|
||||
});
|
||||
@@ -541,7 +546,7 @@ export default class Synchronizer {
|
||||
} catch (error) {
|
||||
if (error.code === 'rejectedByTarget') {
|
||||
this.progressReport_.errors.push(error);
|
||||
this.logger().warn(`Rejected by target: ${path}: ${error.message}`);
|
||||
logger.warn(`Rejected by target: ${path}: ${error.message}`);
|
||||
completeItemProcessing(path);
|
||||
continue;
|
||||
} else {
|
||||
@@ -606,7 +611,7 @@ export default class Synchronizer {
|
||||
// already been done" on the next loop, and sync
|
||||
// will never finish because we'll always end up
|
||||
// here.
|
||||
this.logger().info(`Need to upload a resource, but blob is not present: ${path}`);
|
||||
logger.info(`Need to upload a resource, but blob is not present: ${path}`);
|
||||
await handleCannotSyncItem(ItemClass, syncTargetId, local, 'Trying to upload resource, but only metadata is present.');
|
||||
action = null;
|
||||
} else {
|
||||
@@ -618,7 +623,7 @@ export default class Synchronizer {
|
||||
const localResourceContentPath = result.path;
|
||||
|
||||
if (resource.size >= 10 * 1000 * 1000) {
|
||||
this.logger().warn(`Uploading a large resource (resourceId: ${local.id}, size:${resource.size} bytes) which may tie up the sync process.`);
|
||||
logger.warn(`Uploading a large resource (resourceId: ${local.id}, size:${resource.size} bytes) which may tie up the sync process.`);
|
||||
}
|
||||
|
||||
await this.apiCall('put', remoteContentPath, null, { path: localResourceContentPath, source: 'file', shareId: resource.share_id });
|
||||
@@ -889,7 +894,7 @@ export default class Synchronizer {
|
||||
} catch (error) {
|
||||
if (error.code === 'rejectedByTarget') {
|
||||
this.progressReport_.errors.push(error);
|
||||
this.logger().warn(`Rejected by target: ${path}: ${error.message}`);
|
||||
logger.warn(`Rejected by target: ${path}: ${error.message}`);
|
||||
action = null;
|
||||
} else {
|
||||
error.message = `On file ${path}: ${error.message}`;
|
||||
@@ -905,7 +910,7 @@ export default class Synchronizer {
|
||||
|
||||
if (action == 'createLocal' || action == 'updateLocal') {
|
||||
if (content === null) {
|
||||
this.logger().warn(`Remote has been deleted between now and the delta() call? In that case it will be handled during the next sync: ${path}`);
|
||||
logger.warn(`Remote has been deleted between now and the delta() call? In that case it will be handled during the next sync: ${path}`);
|
||||
continue;
|
||||
}
|
||||
content = ItemClass.filter(content);
|
||||
@@ -951,7 +956,7 @@ export default class Synchronizer {
|
||||
// should always be in info.json now.
|
||||
const existingMasterKey = masterKeyById(content.id);
|
||||
if (!existingMasterKey) {
|
||||
this.logger().info(`Downloaded a master key that was not in info.json - adding it to the store. ID: ${content.id}`);
|
||||
logger.info(`Downloaded a master key that was not in info.json - adding it to the store. ID: ${content.id}`);
|
||||
await MasterKey.save(content);
|
||||
}
|
||||
} else {
|
||||
@@ -1028,7 +1033,7 @@ export default class Synchronizer {
|
||||
// Only log an info statement for this since this is a common condition that is reported
|
||||
// in the application, and needs to be resolved by the user.
|
||||
// Or it's a temporary issue that will be resolved on next sync.
|
||||
this.logger().info(error.message);
|
||||
logger.info(error.message);
|
||||
|
||||
if (error.code === 'failSafe' || error.code === 'lockError') {
|
||||
// Get the message to display on UI, but not in testing to avoid poluting stdout
|
||||
@@ -1037,10 +1042,10 @@ export default class Synchronizer {
|
||||
}
|
||||
} else if (error.code === 'unknownItemType') {
|
||||
this.progressReport_.errors.push(_('Unknown item type downloaded - please upgrade Joplin to the latest version'));
|
||||
this.logger().error(error);
|
||||
logger.error(error);
|
||||
} else {
|
||||
this.logger().error(error);
|
||||
if (error.details) this.logger().error('Details:', error.details);
|
||||
logger.error(error);
|
||||
if (error.details) logger.error('Details:', error.details);
|
||||
|
||||
// Don't save to the report errors that are due to things like temporary network errors or timeout.
|
||||
if (!shim.fetchRequestCanBeRetried(error)) {
|
||||
@@ -1058,7 +1063,7 @@ export default class Synchronizer {
|
||||
this.syncTargetIsLocked_ = false;
|
||||
|
||||
if (this.cancelling()) {
|
||||
this.logger().info('Synchronisation was cancelled.');
|
||||
logger.info('Synchronisation was cancelled.');
|
||||
this.cancelling_ = false;
|
||||
}
|
||||
|
||||
@@ -1068,7 +1073,7 @@ export default class Synchronizer {
|
||||
try {
|
||||
await this.shareService_.maintenance();
|
||||
} catch (error) {
|
||||
this.logger().error('Could not run share service maintenance:', error);
|
||||
logger.error('Could not run share service maintenance:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user