Small improvements
This commit is contained in:
parent
e0b83bbc7a
commit
383e2868c2
3 changed files with 6 additions and 4 deletions
|
|
@ -60,7 +60,7 @@ export class SafeFileSystemOperations implements FileSystemOperations {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getFileSize(path: RelativePath): Promise<number> {
|
public async getFileSize(path: RelativePath): Promise<number> {
|
||||||
this.logger.debug(`Getting size of file '${path}'`);
|
// Logging this would be too noisy
|
||||||
return this.safeOperation(
|
return this.safeOperation(
|
||||||
path,
|
path,
|
||||||
this.decorateToHoldLock(path, async () =>
|
this.decorateToHoldLock(path, async () =>
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ export class Database {
|
||||||
return this.lastSeenUpdateIds.min;
|
return this.lastSeenUpdateIds.min;
|
||||||
}
|
}
|
||||||
|
|
||||||
public addLastSeenUpdateId(value: number): void {
|
public addSeenUpdateId(value: number): void {
|
||||||
const previousMin = this.lastSeenUpdateIds.min;
|
const previousMin = this.lastSeenUpdateIds.min;
|
||||||
this.lastSeenUpdateIds.add(value);
|
this.lastSeenUpdateIds.add(value);
|
||||||
if (previousMin !== this.lastSeenUpdateIds.min) {
|
if (previousMin !== this.lastSeenUpdateIds.min) {
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,8 @@ export class Syncer {
|
||||||
|
|
||||||
let hasLockToRelease = false;
|
let hasLockToRelease = false;
|
||||||
if (document === undefined) {
|
if (document === undefined) {
|
||||||
// Let's avoid the same documents getting created in parallel multiple times
|
// Let's avoid the same documents getting created in parallel multiple times.
|
||||||
|
// There might be multiple tasks waiting for the lock
|
||||||
await this.remoteDocumentsLock.waitForLock(
|
await this.remoteDocumentsLock.waitForLock(
|
||||||
remoteVersion.documentId
|
remoteVersion.documentId
|
||||||
);
|
);
|
||||||
|
|
@ -396,6 +397,7 @@ export class Syncer {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// We're either the first one to get the lock, so we have to create the document in `unrestrictedSyncRemotelyUpdatedFile`
|
||||||
if (document === undefined) {
|
if (document === undefined) {
|
||||||
await this.syncQueue.add(async () =>
|
await this.syncQueue.add(async () =>
|
||||||
this.internalSyncer.unrestrictedSyncRemotelyUpdatedFile(
|
this.internalSyncer.unrestrictedSyncRemotelyUpdatedFile(
|
||||||
|
|
@ -427,7 +429,7 @@ export class Syncer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.database.addLastSeenUpdateId(remoteVersion.vaultUpdateId);
|
this.database.addSeenUpdateId(remoteVersion.vaultUpdateId);
|
||||||
} finally {
|
} finally {
|
||||||
if (hasLockToRelease) {
|
if (hasLockToRelease) {
|
||||||
this.remoteDocumentsLock.unlock(remoteVersion.documentId);
|
this.remoteDocumentsLock.unlock(remoteVersion.documentId);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue