Skip to content

Also close windows of folders that are on an ejected disk #2

Description

@probonopd

Possibly along these lines but this must be tested on Windows and on Linux:

def handle_drive_removal(drive):
    normalized_drive = os.path.normpath(drive)
    removed_volume_name = QtCore.QStorageInfo(normalized_drive).displayName()
    
    windows_to_close = []
    for window in open_windows.values():
        path = window.folder_path
        if os.path.normpath(path).startswith(normalized_drive) or window.volume_name == removed_volume_name:
            windows_to_close.append(window)
    
    for window in windows_to_close:
        window.close()
    
    desktop_window.refresh_view()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions