Fix agent behaviour
This commit is contained in:
parent
b4783d1007
commit
c69f84edf5
4 changed files with 16 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import type { FileSystemOperations } from "dist/types";
|
||||
import type { RelativePath } from "src/persistence/database";
|
||||
import type { FileSystemOperations } from "./filesystem-operations";
|
||||
|
||||
export class FileNotFoundError extends Error {
|
||||
public constructor(message: string) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import type {
|
|||
} from "../persistence/database";
|
||||
import type { Logger } from "src/tracing/logger";
|
||||
import { retriedFetchFactory } from "src/utils/retried-fetch";
|
||||
import type { SyncSettings } from "dist/types";
|
||||
import type { Settings } from "src/persistence/settings";
|
||||
|
||||
export interface CheckConnectionResult {
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ export class Syncer {
|
|||
await this.operations.read(relativePath);
|
||||
const contentHash = hash(contentBytes);
|
||||
|
||||
// todo: make this smarter so that offline files can be renamed & edited at the same time
|
||||
const originalFile = findMatchingFileBasedOnHash(
|
||||
contentHash,
|
||||
locallyPossiblyDeletedFiles
|
||||
|
|
|
|||
|
|
@ -224,6 +224,16 @@ export class MockAgent extends MockClient {
|
|||
|
||||
private async renameFileAction(files: RelativePath[]): Promise<void> {
|
||||
const file = choose(files);
|
||||
|
||||
// We can't edit files offline that have been renamed while offline.
|
||||
// Otherwise, the resolution logic couldn't handle it.
|
||||
if (this.doNotTouch.includes(file)) {
|
||||
this.client.logger.info(
|
||||
`Skipping file ${file} because it has been updated while offline`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const newName = this.getFileName();
|
||||
|
||||
if (await this.exists(newName)) {
|
||||
|
|
@ -242,7 +252,7 @@ export class MockAgent extends MockClient {
|
|||
const file = choose(files);
|
||||
|
||||
// We can't edit files offline that have been renamed while offline.
|
||||
// Othwersie, the resolution logic couldn't handle it.
|
||||
// Otherwise, the resolution logic couldn't handle it.
|
||||
if (this.doNotTouch.includes(file)) {
|
||||
this.client.logger.info(
|
||||
`Skipping file ${file} because it has been renamed while offline`
|
||||
|
|
@ -254,6 +264,9 @@ export class MockAgent extends MockClient {
|
|||
this.client.logger.info(
|
||||
`Decided to update file ${file} with ${content}`
|
||||
);
|
||||
if (!this.client.settings.getSettings().isSyncEnabled) {
|
||||
this.doNotTouch.push(file);
|
||||
}
|
||||
await this.atomicUpdateText(file, (old) => old + ` |${content}| `);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue