Improve agent action logic with forbidden renames

This commit is contained in:
Andras Schmelczer 2025-02-24 22:47:09 +00:00
parent e186a593ff
commit becd7c222e
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -47,6 +47,15 @@ export class MockAgent extends MockClient {
this.client.logger.info("Agent initialized");
}
public async delete(path: RelativePath): Promise<void> {
assert(
this.doDeletes,
`Agent ${this.name} tried to delete file ${path} while doDeletes is false`
);
await super.delete(path);
}
public async act(): Promise<void> {
const options: (() => Promise<unknown>)[] = [
this.createFileAction.bind(this),
@ -242,7 +251,7 @@ export class MockAgent extends MockClient {
this.client.logger.info(`Decided to rename file ${file} to ${newName}`);
if (!this.client.settings.getSettings().isSyncEnabled) {
this.doNotTouch.push(newName);
this.doNotTouch.push(file, newName);
}
return this.rename(file, newName);