1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Merge branch 'release-1.0' into dev

This commit is contained in:
Laurent Cozic 2020-09-11 23:34:44 +01:00
commit 1108e8c28a
5 changed files with 27 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import LockHandler from 'lib/services/synchronizer/LockHandler';
import MigrationHandler from 'lib/services/synchronizer/MigrationHandler';
import { Dirnames } from 'lib/services/synchronizer/utils/types';
// To create a sync target snapshot for the current syncVersion:
// - In test-utils, set syncTargetName_ to "filesystem"
@ -70,6 +71,14 @@ describe('synchronizer_MigrationHandler', function() {
done();
});
it('should init a new sync target', asyncTest(async () => {
// Check that basic folders "locks" and "temp" are created for new sync targets.
await migrationHandler().upgrade(1);
const result = await fileApi().list();
expect(result.items.filter((i:any) => i.path === Dirnames.Locks).length).toBe(1);
expect(result.items.filter((i:any) => i.path === Dirnames.Temp).length).toBe(1);
}), specTimeout);
it('should not allow syncing if the sync target is out-dated', asyncTest(async () => {
await synchronizer().start();
await fileApi().put('info.json', `{"version":${Setting.value('syncVersion') - 1}}`);

View File

@ -50,6 +50,7 @@ const KeychainServiceDriver = require('lib/services/keychain/KeychainServiceDriv
const KeychainServiceDriverDummy = require('lib/services/keychain/KeychainServiceDriver.dummy').default;
const md5 = require('md5');
const S3 = require('aws-sdk/clients/s3');
const { Dirnames } = require('lib/services/synchronizer/utils/types');
const databases_ = [];
let synchronizers_ = [];
@ -438,6 +439,7 @@ async function initFileApi() {
fileApi.setLogger(logger);
fileApi.setSyncTargetId(syncTargetId_);
fileApi.setTempDirName(Dirnames.Temp);
fileApi.requestRepeatCount_ = isNetworkSyncTarget_ ? 1 : 0;
fileApis_[syncTargetId_] = fileApi;

View File

@ -105,7 +105,17 @@ class ElectronAppWrapper {
// Waiting for one of the ready events might work but they might not be triggered if there's an error, so
// the easiest is to use a timeout. Keep in mind that if you get a white window on Windows it might be due
// to this line though.
if (debugEarlyBugs) setTimeout(() => this.win_.webContents.openDevTools(), 3000);
if (debugEarlyBugs) {
setTimeout(() => {
try {
this.win_.webContents.openDevTools();
} catch (error) {
// This will throw an exception "Object has been destroyed" if the app is closed
// in less that the timeout interval. It can be ignored.
console.warn('Error opening dev tools', error);
}
}, 3000);
}
this.win_.on('close', (event) => {
// If it's on macOS, the app is completely closed only if the user chooses to close the app (willQuitApp_ will be true)

View File

@ -90,9 +90,11 @@ export default class MigrationHandler extends BaseService {
// it the lock handler will break. So we create the directory now.
// Also if the sync target version is 0, it means it's a new one so we need the
// lock folder first before doing anything else.
// Temp folder is needed too to get remoteDate() call to work.
if (syncTargetInfo.version === 0 || syncTargetInfo.version === 1) {
this.logger().info('MigrationHandler: Sync target version is 0 or 1 - creating "locks" directory:', syncTargetInfo);
this.logger().info('MigrationHandler: Sync target version is 0 or 1 - creating "locks" and "temp" directory:', syncTargetInfo);
await this.api_.mkdir(Dirnames.Locks);
await this.api_.mkdir(Dirnames.Temp);
}
this.logger().info('MigrationHandler: Acquiring exclusive lock');

View File

@ -305,6 +305,8 @@ class Synchronizer {
let syncLock = null;
try {
this.api().setTempDirName(Dirnames.Temp);
try {
const syncTargetInfo = await this.migrationHandler().checkCanSync();
@ -321,8 +323,6 @@ class Synchronizer {
throw error;
}
this.api().setTempDirName(Dirnames.Temp);
syncLock = await this.lockHandler().acquireLock('sync', this.appType_, this.clientId_);
this.lockHandler().startAutoLockRefresh(syncLock, (error) => {