Skip to content

Move folder instead of delete#1362

Merged
dajimenezriv-internxt merged 72 commits into
mainfrom
move-folder-instead-of-delete
May 9, 2026
Merged

Move folder instead of delete#1362
dajimenezriv-internxt merged 72 commits into
mainfrom
move-folder-instead-of-delete

Conversation

@dajimenezriv-internxt
Copy link
Copy Markdown
Contributor

@dajimenezriv-internxt dajimenezriv-internxt commented Apr 30, 2026

What

Currently when a folder was deleted in cloud we were deleting it in local using trash. However, this had 2 issues:

  1. if the folder contained items that were not placeholders we were sending them to the trash when deleting the folder.
  2. if the folder was big it could lead to a lot of delete events that could imply deleting files in the cloud (however just the root folder was deleted).

To solve the first issue we have implemented a C++ solution that iterates the folder and checks for non placeholder items. I've added a test that tests against an empty folder, a folder with all placeholders (dehydrated and hydrated) and also with a file that is not a placeholder.

To solve the second issue first we move the folder to a temporal folder in the same volume called C:/.internxt_trash and then we send it to the trash, so we just receive one delete event.

@dajimenezriv-internxt dajimenezriv-internxt self-assigned this Apr 30, 2026
Base automatically changed from organize-c++-code-3 to main May 6, 2026 09:04
@@ -0,0 +1,61 @@
#pragma once
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with a folder with 500 items and took 0.02s.

Comment on lines +16 to +18
const mkdirMock = vi.mocked(mkdir);
const renameMock = vi.mocked(rename);
const rmMock = vi.mocked(rm);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has the rule against using vi.mock been abolished? Because here you could use deepMocked to mock the functions in fs/promises.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, you are right, changed.

props.locals = new Map();
// When
await deleteItemPlaceholder(props);
await deleteItemPlaceholder(props as any);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this type assert necessary now when it wasn't necessary before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a trying with a new way by using TestProps in the let props instead of using mockProps. So now the type is Partial and needs to casting to any.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 8, 2026

@dajimenezriv-internxt dajimenezriv-internxt merged commit 5476908 into main May 9, 2026
8 of 9 checks passed
@dajimenezriv-internxt dajimenezriv-internxt deleted the move-folder-instead-of-delete branch May 9, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants