Update variable name
This commit is contained in:
parent
e14fe4240e
commit
cd7fe5fe39
1 changed files with 19 additions and 17 deletions
|
|
@ -206,13 +206,13 @@ export class Syncer {
|
||||||
const contentBytes = await this.operations.read(relativePath);
|
const contentBytes = await this.operations.read(relativePath);
|
||||||
let contentHash = hash(contentBytes);
|
let contentHash = hash(contentBytes);
|
||||||
|
|
||||||
const metadata = this.database.getDocument(relativePath);
|
const localMetadata = this.database.getDocument(relativePath);
|
||||||
if (metadata) {
|
if (localMetadata) {
|
||||||
Logger.getInstance().debug(
|
Logger.getInstance().debug(
|
||||||
`Document metadata already exists for ${relativePath}, it must have been downloaded from the server`
|
`Document metadata already exists for ${relativePath}, it must have been downloaded from the server`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (metadata.hash === contentHash) {
|
if (localMetadata.hash === contentHash) {
|
||||||
this.history.addHistoryEntry({
|
this.history.addHistoryEntry({
|
||||||
status: SyncStatus.NO_OP,
|
status: SyncStatus.NO_OP,
|
||||||
relativePath,
|
relativePath,
|
||||||
|
|
@ -283,10 +283,10 @@ export class Syncer {
|
||||||
SyncType.UPDATE,
|
SyncType.UPDATE,
|
||||||
SyncSource.PUSH,
|
SyncSource.PUSH,
|
||||||
async () => {
|
async () => {
|
||||||
const metadata = this.database.getDocument(
|
const localMetadata = this.database.getDocument(
|
||||||
oldPath ?? relativePath
|
oldPath ?? relativePath
|
||||||
);
|
);
|
||||||
if (!metadata) {
|
if (!localMetadata) {
|
||||||
if (this.database.getDocument(relativePath)) {
|
if (this.database.getDocument(relativePath)) {
|
||||||
this.history.addHistoryEntry({
|
this.history.addHistoryEntry({
|
||||||
status: SyncStatus.NO_OP,
|
status: SyncStatus.NO_OP,
|
||||||
|
|
@ -305,7 +305,10 @@ export class Syncer {
|
||||||
const contentBytes = await this.operations.read(relativePath);
|
const contentBytes = await this.operations.read(relativePath);
|
||||||
let contentHash = hash(contentBytes);
|
let contentHash = hash(contentBytes);
|
||||||
|
|
||||||
if (metadata.hash === contentHash && oldPath === undefined) {
|
if (
|
||||||
|
localMetadata.hash === contentHash &&
|
||||||
|
oldPath === undefined
|
||||||
|
) {
|
||||||
this.history.addHistoryEntry({
|
this.history.addHistoryEntry({
|
||||||
status: SyncStatus.NO_OP,
|
status: SyncStatus.NO_OP,
|
||||||
relativePath,
|
relativePath,
|
||||||
|
|
@ -316,8 +319,8 @@ export class Syncer {
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.syncService.put({
|
const response = await this.syncService.put({
|
||||||
documentId: metadata.documentId,
|
documentId: localMetadata.documentId,
|
||||||
parentVersionId: metadata.parentVersionId,
|
parentVersionId: localMetadata.parentVersionId,
|
||||||
relativePath,
|
relativePath,
|
||||||
contentBytes,
|
contentBytes,
|
||||||
createdDate: updateTime,
|
createdDate: updateTime,
|
||||||
|
|
@ -383,7 +386,7 @@ export class Syncer {
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.database.moveDocument({
|
await this.database.moveDocument({
|
||||||
documentId: metadata.documentId,
|
documentId: localMetadata.documentId,
|
||||||
oldRelativePath: oldPath ?? relativePath,
|
oldRelativePath: oldPath ?? relativePath,
|
||||||
relativePath: response.relativePath,
|
relativePath: response.relativePath,
|
||||||
parentVersionId: response.vaultUpdateId,
|
parentVersionId: response.vaultUpdateId,
|
||||||
|
|
@ -410,8 +413,8 @@ export class Syncer {
|
||||||
SyncType.DELETE,
|
SyncType.DELETE,
|
||||||
SyncSource.PUSH,
|
SyncSource.PUSH,
|
||||||
async () => {
|
async () => {
|
||||||
const metadata = this.database.getDocument(relativePath);
|
const localMetadata = this.database.getDocument(relativePath);
|
||||||
if (!metadata) {
|
if (!localMetadata) {
|
||||||
this.history.addHistoryEntry({
|
this.history.addHistoryEntry({
|
||||||
status: SyncStatus.NO_OP,
|
status: SyncStatus.NO_OP,
|
||||||
relativePath,
|
relativePath,
|
||||||
|
|
@ -422,7 +425,7 @@ export class Syncer {
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.syncService.delete({
|
await this.syncService.delete({
|
||||||
documentId: metadata.documentId,
|
documentId: localMetadata.documentId,
|
||||||
relativePath,
|
relativePath,
|
||||||
createdDate: new Date(), // We got the event now, so it must have been deleted just now
|
createdDate: new Date(), // We got the event now, so it must have been deleted just now
|
||||||
});
|
});
|
||||||
|
|
@ -448,11 +451,11 @@ export class Syncer {
|
||||||
SyncType.UPDATE,
|
SyncType.UPDATE,
|
||||||
SyncSource.PULL,
|
SyncSource.PULL,
|
||||||
async () => {
|
async () => {
|
||||||
const currentVersion = this.database.getDocumentByDocumentId(
|
const localMetadata = this.database.getDocumentByDocumentId(
|
||||||
remoteVersion.documentId
|
remoteVersion.documentId
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!currentVersion) {
|
if (!localMetadata) {
|
||||||
if (remoteVersion.isDeleted) {
|
if (remoteVersion.isDeleted) {
|
||||||
this.history.addHistoryEntry({
|
this.history.addHistoryEntry({
|
||||||
status: SyncStatus.NO_OP,
|
status: SyncStatus.NO_OP,
|
||||||
|
|
@ -491,7 +494,7 @@ export class Syncer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [relativePath, metadata] = currentVersion;
|
const [relativePath, metadata] = localMetadata;
|
||||||
if (metadata.parentVersionId === remoteVersion.vaultUpdateId) {
|
if (metadata.parentVersionId === remoteVersion.vaultUpdateId) {
|
||||||
Logger.getInstance().debug(
|
Logger.getInstance().debug(
|
||||||
`Document ${relativePath} is already up to date`
|
`Document ${relativePath} is already up to date`
|
||||||
|
|
@ -502,7 +505,6 @@ export class Syncer {
|
||||||
if (relativePath !== remoteVersion.relativePath) {
|
if (relativePath !== remoteVersion.relativePath) {
|
||||||
await waitForDocumentLock(relativePath);
|
await waitForDocumentLock(relativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (remoteVersion.isDeleted) {
|
if (remoteVersion.isDeleted) {
|
||||||
await this.operations.remove(relativePath);
|
await this.operations.remove(relativePath);
|
||||||
|
|
@ -523,7 +525,7 @@ export class Syncer {
|
||||||
|
|
||||||
if (currentHash !== metadata.hash) {
|
if (currentHash !== metadata.hash) {
|
||||||
Logger.getInstance().info(
|
Logger.getInstance().info(
|
||||||
`Document ${relativePath} has been updated both remotely and locally, skipping until the event is processed`
|
`Document ${relativePath} has been updated both remotely and locally, letting the local file update event handle it`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue