Skip to content

Commit

Permalink
[Microsoft] Log scrubbed folders and prevent accidental root deletion (
Browse files Browse the repository at this point in the history
…#9217)

Description
---
Fixes dust-tt/tasks#1765

Deleting a root (user selection for sync) should always be explicit,
before deleting the underlying folder

Risks
---
New monitors popping on delete folders activity. This will allow us to
fix code paths leading to implicit root deletion

Deploy
---
connectors
  • Loading branch information
philipperolet authored Dec 9, 2024
1 parent 06cb613 commit c8bfd88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions connectors/src/connectors/microsoft/temporal/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,14 @@ async function scrubRemovedFolders({

const dataSourceConfig = dataSourceConfigFromConnector(connector);

logger.info(
{
connectorId: connector.id,
nodes: nodes.map((n) => n.toJSON()),
},
"Scrubbing removed folders"
);

for (const node of nodes) {
if (node.nodeType === "file") {
await deleteFile({
Expand Down
5 changes: 4 additions & 1 deletion connectors/src/connectors/microsoft/temporal/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,10 @@ export async function deleteFolder({
);

if (root) {
await root.delete();
// Roots represent the user selection for synchronization As such, they
// should be deleted first, explicitly by users, before deleting the
// underlying folder
throw new Error("Unexpected: attempt to delete folder with root node");
}

if (folder) {
Expand Down

0 comments on commit c8bfd88

Please sign in to comment.