chore: add safe readdir and stat functions#341
Open
AlexisMora wants to merge 7 commits into
Open
Conversation
|
egalvis27
requested changes
May 13, 2026
| if (error) return { error }; | ||
|
|
||
| for (const dirent of dirents) { | ||
| const currentPath = path.join(absolutePath.toString(), dirent.name) as AbsolutePath; |
There was a problem hiding this comment.
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>> { |
There was a problem hiding this comment.
Since these functions are being separated, the handling of parameters as objects should be maintained
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What is Changed / Added
Added
safeAccess,safeReaddirandsafeStatto handle such errors when performing these opeationsGot 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 therunmethod from the oldLocalTreeBuilder, andtraversemethod 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
BackupServicenow its handled and the file is skipped and also notified to the userAlso, 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