Bug 428392

Summary: Impossible to "eject" a mounted ISO image via Places panel
Product: [Applications] dolphin Reporter: Patrick Silva <bugseforuns>
Component: plugins: ISO mountingAssignee: Kwon-Young Choi <kwon-young.choi>
Status: CONFIRMED ---    
Severity: normal CC: burster, gudvinr+kde, katyaberezyaka, kfm-devel, nate, popov895, spzakulec, witchhunterpro, zawertun
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:

Description Patrick Silva 2020-10-28 13:39:35 UTC
SUMMARY
When I unmount an ISO image mounted with "Mount ISO" plugin,
it remains under "Devices" section of Places panel and there is no "Eject" option
to remove it. Reboot is the only solution.

STEPS TO REPRODUCE
1. open Dolphin
2. right-click on an ISO image, choose "Mount ISO"
3. unmount the just mounted ISO image

OBSERVED RESULT
explained above

EXPECTED RESULT
a way to "eject" ISO images should exist

SOFTWARE/OS VERSIONS
Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.20.80
KDE Frameworks Version: 5.76.0
Qt Version: 5.15.0
Comment 1 Kwon-Young Choi 2020-10-28 13:44:59 UTC
(In reply to Patrick Silva from comment #0)
> SUMMARY
> When I unmount an ISO image mounted with "Mount ISO" plugin,
> it remains under "Devices" section of Places panel and there is no "Eject"
> option
> to remove it. Reboot is the only solution.
> 
> STEPS TO REPRODUCE
> 1. open Dolphin
> 2. right-click on an ISO image, choose "Mount ISO"
> 3. unmount the just mounted ISO image

How do you unmount the ISO image ?
Do you use the Dolphin left pane called Place or do you use the contextual menu of the ISO file ?

Normally, you can remove the ISO file by using the "Unmount ISO" entry of the contextual menu of the ISO file.
Comment 2 Patrick Silva 2020-10-28 14:03:37 UTC
clearer step 3:
3. right-click on the ISO image under "Devices" section of Places panel, choose "Unmount"

OBSERVED RESULT
the icon under "Devices" indicates successful unmounting but the ISO image is not "ejected".
If I right-click on the same ISO image and select "Unmount ISO" (unexpectedly available in the context menu because the ISO image is already unmounted),
the ISO image is "ejected" and disappears from "Devices" section.
Comment 3 Kwon-Young Choi 2020-10-28 14:08:57 UTC
(In reply to Patrick Silva from comment #2)
> clearer step 3:
> 3. right-click on the ISO image under "Devices" section of Places panel,
> choose "Unmount"
> 
> OBSERVED RESULT
> the icon under "Devices" indicates successful unmounting but the ISO image
> is not "ejected".
> If I right-click on the same ISO image and select "Unmount ISO"
> (unexpectedly available in the context menu because the ISO image is already
> unmounted),
> the ISO image is "ejected" and disappears from "Devices" section.

Ok, so this is the expected behavior.
The idea is that the "Mount" and "Unmount" entry on the contextual menu of the ISO file act as if you physically inserted or ejected the CD-ROM.

It would be nice to be able to remove the unmounted iso file from Dolphin's Place pane directly but it is much more difficult to implement for me since it involves modifying Dolphin's code.
Comment 4 Patrick Silva 2023-01-26 21:39:29 UTC
*** Bug 464851 has been marked as a duplicate of this bug. ***
Comment 5 witchhunter 2023-04-25 21:28:43 UTC
As a workaround one could implement the following Dolphin service:

[Desktop Action unmount]
Exec=bash -c 'readarray -t images < <(losetup -nO NAME); [ -n "${images[@]}" ] && for item in "${images[@]}"; do udisksctl loop-delete -b "$item"; done '
Icon=edit-clear
Name=Clear ISOs

[Desktop Entry]
Actions=unmount;
Icon=application-x-iso
MimeType=all/all
ServiceTypes=KonqPopupMenu/Plugin
Type=Service
X-KDE-StartupNotify=false


As a benefit you wont have to search for unmounted ISO's.
Comment 6 witchhunter 2023-04-26 11:08:06 UTC
(In reply to witchhunter from comment #5)
> Exec=bash -c 'readarray -t images < <(losetup -nO NAME); [ -n "${images[@]}"
> ] && for item in "${images[@]}"; do udisksctl loop-delete -b "$item"; done '

Ups,
Actually the line should be 
Exec=bash -c 'readarray -t images < <(losetup -nO NAME); [ -n "${images[0]}" ] && for item in "${images[@]}"; do udisksctl loop-delete -b "$item"; done '