Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: If a folder is moved or deleted while it is opened in a explorer tab, the explorer tab gets into a broken state #19

Open
pkerschbaum opened this issue Jan 17, 2022 · 0 comments
Labels
kind/bug Something isn't working

Comments

@pkerschbaum
Copy link
Owner

pkerschbaum commented Jan 17, 2022

Current Behavior

If a folder is moved or deleted while it is opened in a explorer tab, the explorer tab gets into a broken state.

Example

A explorer tab has this directory opened: home\test-directory\sub-directory.
If home, test-subdirectory or sub-directory is moved (because it is renamed in a second tab; it is renamed using the native file explorer; it is deleted; etc.), then the tab remains present but almost every action performed in this tab will throw an error.
It is possible to get into a healthy state again if the user navigates up the directory hierarchy or changes the CWD (current working directory) using the change CWD form (behind the Breadcrumbs menu). It is also possible to just close the tab.

Reason for the bug

Explorer tabs do not react to their CWD getting invalid/detached.

Suggested Solution

The Windows file explorer seems to navigate up the file hierarchy until it finds an ancestor which is valid. In case no ancestor is valid (e.g. the path F:\test was open, and the device having the drive letter F got detached), the file explorer just closes.

I think it is sufficient for our file explorer if it just removes explorer tabs which CWD got detached.

Implementation Notes

A single explorer tab does already register a file system watcher for each of its CWD segments. For example, if the CWD is home\test-directory\sub-directory, three file system watchers are active:

  • home
  • home\test-directory
  • home\test-directory\sub-directory

This is done by creating a CwdSegmentContextProvider for each CWD segment...

{cwdSegments.map((segment, idx) => {
const isLastSegment = idx === cwdSegments.length - 1;
return (
<CwdSegmentContextProvider
key={uriHelper.getComparisonKey(segment.uri)}
segmentIdx={idx}
>
<ActionsBarAndResourcesView
isLastSegment={isLastSegment}
activeAnimationVariant={activeAnimationVariant}
/>
</CwdSegmentContextProvider>
);
})}

...and this CwdSegmentContextProvider "listens" for the resources in its directory:

const { resources } = useResourcesOfDirectory(uri);

useResourcesOfDirectory returns a property error. We could check if that error is set and if so, remove not just the CWD segment but the entire explorer panel from the global state.

@pkerschbaum pkerschbaum added the kind/bug Something isn't working label Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant