Skip to content

Commit b473972

Browse files
committed
Fixes order of operations when unmounting SSHFS folder
> see #54
1 parent 6a2ad11 commit b473972

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
### Fixed
1515

1616
- Unmount on macOS
17+
- Unmount race conditions related to SSHFS mount point still present in project opened folders
1718

1819
### Removed
1920

sshubl/actions.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -343,26 +343,24 @@ def run(self):
343343
f"{'M' if self.do_mount else 'Unm'}ounting ssh://{ssh_session}{self.remote_path}...",
344344
)
345345
try:
346+
# Do-mounting : mount -> add folder to project
347+
# Do-unmounting : remove folder from project -> unmount
346348
if self.do_mount:
347349
mount_path = mount_sshfs(
348350
self.identifier, typing.cast(PurePath, self.remote_path), self.mount_path
349351
)
352+
if mount_path is None:
353+
return
354+
add_to_project_folders(
355+
str(mount_path), f"{ssh_session}{self.remote_path}", self.view.window()
356+
)
350357
else:
351358
mount_path = typing.cast(Path, self.mount_path)
359+
remove_from_project_folders(str(mount_path), self.view.window())
352360
umount_sshfs(mount_path)
353361
finally:
354362
self.view.erase_status("zz_mounting_sshfs")
355363

356-
if mount_path is None:
357-
return
358-
359-
if self.do_mount:
360-
add_to_project_folders(
361-
str(mount_path), f"{ssh_session}{self.remote_path}", self.view.window()
362-
)
363-
else:
364-
remove_from_project_folders(str(mount_path), self.view.window())
365-
366364
# store/remove mount path in/from SSH session metadata
367365
with project_data_lock:
368366
if self.do_mount:

sshubl/listeners.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,14 @@ def on_pre_close_window(self, window):
8787
# attempts will occur when re-opening the same project
8888
for identifier, ssh_session in SshSession.get_all_from_project_data(window).items():
8989
for mount_path in ssh_session.mounts:
90+
remove_from_project_folders(mount_path, window)
9091
umount_sshfs(Path(mount_path))
9192

9293
ssh_disconnect(uuid.UUID(identifier))
9394

9495
ssh_session.is_up = False
9596
ssh_session.set_in_project_data(window)
9697

97-
# remove mounts from project folders
98-
for mount in ssh_session.mounts:
99-
remove_from_project_folders(mount, window)
100-
10198

10299
class ViewEventListener(sublime_plugin.ViewEventListener):
103100
def on_load_async(self):

0 commit comments

Comments
 (0)