Skip to content

chore: add safe readdir and stat functions#341

Open
AlexisMora wants to merge 7 commits into
feat/go-fuse-daemonfrom
fix/br-2059-dont-follow-symlinks
Open

chore: add safe readdir and stat functions#341
AlexisMora wants to merge 7 commits into
feat/go-fuse-daemonfrom
fix/br-2059-dont-follow-symlinks

Conversation

@AlexisMora
Copy link
Copy Markdown

@AlexisMora AlexisMora commented May 13, 2026

What is Changed / Added

Added safeAccess, safeReaddir and safeStat to handle such errors when performing these opeations

Got rid of the old "LocalTreeBuilder" as it was untested and done with the old, legacy code with diod. instead I refactored into the src/backend/features/backup/local-tree/ module, wher i created the entry point method "build local tree" that substitues the run method from the old LocalTreeBuilder, and traverse method to populate the local tree needed to perform the backup process.

Now, while traversing the three, any broken symlink or any other symlink, will just be added to the "skippedItems" list, so that we can push these skiped items that wont be uploaded into the issues window and notify the user
(I have added a todo to enhance the issues window to allow per-file notification)

Also, while testing i found out that the upload mechanism can file if we try to upload a file with restricted access or in general if the stream gets an error, so I added an access check to avoid the upload if we can "access" that given file, also notifying the user in the process (That means that we only skip the upload of files if we cant access them, upload is also retried if we get rate limits or internal server errors)


Why

When building the try, there was a corner case when reading symlinks or broken symlinks, it would throw an exception that would be cached on BackupService now its handled and the file is skipped and also notified to the user

Also, there was another corner case that when trying to upload/update a file, it would also not be managed by the proper function, now, we handle these cases and skipp and notify the user as well

@AlexisMora AlexisMora marked this pull request as ready for review May 13, 2026 16:14
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
13.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

if (error) return { error };

for (const dirent of dirents) {
const currentPath = path.join(absolutePath.toString(), dirent.name) as AbsolutePath;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is already a function to create an absolutePath and avoid these type assertions

Comment on lines +14 to +18
export async function traverse(
tree: LocalTree,
currentFolder: AbsolutePath,
rootFolder: AbsolutePath,
): Promise<Result<TraverseResult, DriveDesktopError>> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since these functions are being separated, the handling of parameters as objects should be maintained

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