Skip to content

List drives that aren't mounted yet, and mount them on a click or as they're plugged in - #22

Open
AyushKr2003 wants to merge 17 commits into
omacom:mainfrom
AyushKr2003:unmounted-drives
Open

AyushKr2003 wants to merge 17 commits into
omacom:mainfrom
AyushKr2003:unmounted-drives

Conversation

@AyushKr2003

@AyushKr2003 AyushKr2003 commented Nov 11, 2026 •

Copy link
Copy Markdown

Devices lists only drives that are already mounted. On a machine that also has Windows and another Linux install, none of those partitions show until they're mounted by hand, while Nautilus lists them all and mounts one on a click.

Letting go of a drive is now main's own (Places::eject and leave, the eject button and the drive menu, from #32 and #53), so this branch is merged with main and builds on that rather than adding a second way to eject.

What changes

  • Devices lists GIO's volumes, the same list Nautilus shows. udisks leaves out the system's own and hidden partitions (EFI, MSR, recovery), so on a dual-boot laptop it reads Acer (Windows), 53 GB Volume, ryoku (another Arch). A mounted volume is the row physicalDrives already makes for it (free space, Eject or Unmount), with its volume id added; mounted drives GIO doesn't know (an fstab mount under /mnt) follow, as before, and a mounted volume physicalDrives leaves out (the system's own) stays out. The list follows plugging, mounting and unmounting at once via GVolumeMonitor, instead of waiting for the 15-second poll.
  • A click on a drive that isn't mounted mounts it and opens it (g_volume_mount), and so do ⏎ and the drive menu's Mount. udisks asks the session's polkit agent where it needs permission. An encrypted drive's passphrase is asked for in the window through the mount prompt, which then reads "Unlock" and shows only a Passphrase field. The passphrase isn't saved. A drive's questions go to the user, as an unverified server's do.
  • Drives plugged in mount by themselves when udisks marks them to (removable media; internal partitions aren't). This respects GNOME's org.gnome.desktop.media-handling automount when that schema is installed. A desktop automounter (udiskie, a shell) gets two seconds' head start, so a drive isn't mounted twice and an encrypted one isn't asked for its passphrase twice. The mount goes through the last window used, so it can ask for a passphrase. "TESTSTICK is mounted" shows as a notice.
  • A drive unmounted from anywhere (another app, a terminal, pulled out) is left at once through Places::leave, so panes go home and previews close, as they do for main's own eject.
  • An encrypted drive that unlocks with nothing mountable inside (no filesystem, LVM) says so, and one that's still not mounted a minute after its passphrase is given up on. GVfs reports both as "cancelled", which used to look like nothing happening.

The GIO code lives in a new Drives class (drives.h/.cpp). Mounter gains mountVolume() alongside mount(), sharing its prompt, and Places::devicesFrom puts the two lists together. Unmounted rows have no path and no release, so the eject button and Format stay away from them.

Tested

  • Builds clean after the merge with main. bin/test: 194 passed, including the reworked placesListDrivesNotMountedYet and englishCatalogMatchesTheSources (the new strings are in en.json). The one failure, previewerPicksAViewerForEachType (CR2 → image), depends on the Qt image plugins installed here and fails the same way on main.
  • Before the merge, on Omarchy (Hyprland, Qt 6.12, gvfs 1.62, udisks 2.11), dual boot with Windows and a second Arch:
    • Devices listed the two NTFS partitions and the second Arch's btrfs, and not EFI/MSR/recovery.
    • Clicking the btrfs partition mounted it at /run/media/<user>/ryoku through the polkit agent and opened it. Unmounting it from a terminal (gio mount -u) sent the pane home.
    • A FAT image attached with udisksctl loop-setup (udiskie paused) was mounted by Folio after the delay, with the notice. With udiskie running, udiskie mounted it and Folio left it alone.
    • A LUKS2 image showed the Unlock prompt. The passphrase unlocked it, and since it holds no filesystem, the window said so.

@greptile-apps

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes reach Folio's local drive and sidebar workflows.

The stale-row fix needs one more case before merging: ejected optical media can still leave an old mounted row.

Findings

  1. P1 Unmounted drives keep old rows ▶

Summary

Folio lists unmounted drives and mounts them when opened. It also mounts eligible removable drives automatically and leaves folders when their drive disappears.

  • The Devices list shows unmounted drives and opens them on request.
  • Eligible removable drives mount after a short wait when plugged in.
  • Panes leave a drive as soon as GIO reports its mount is gone.
  • Git ignores the package build directory.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  G[GIO volumes] --> P[Places combines drive lists]
  C[Last completed mount read] --> P
  P --> F[Filter stale mounted rows]
  F --> S[Sidebar Devices]
  S --> M[Mount and open on click]
Loading

Reviews (16) · Last reviewed commit: "Leave out a stalled reading's drives GIO..." · Reviewed by Greptile

Comment thread src/drives.cpp Resolved
Comment thread src/windows.cpp Resolved
Comment thread src/mounter.cpp Resolved
Comment thread src/Sidebar.qml Resolved
Comment thread src/mounter.cpp Resolved
Devices listed only what was already mounted, so another system's
partitions and a stick that nothing had mounted never showed. It now
lists GIO's volumes, as Nautilus does: udisks leaves out the system's own
and hidden partitions (EFI, recovery), and the list follows plugging,
mounting and unmounting at once instead of on the 15-second poll.

- A click on one that isn't mounted mounts it and opens it. udisks asks
  the session's polkit agent where it needs permission, and an encrypted
  drive's passphrase is asked for in the window, kept for no session.
- A drive plugged in that udisks marks to mount by itself is mounted,
  unless GNOME's automount setting is off. A desktop automounter (udiskie,
  a shell) gets two seconds' head start, so nothing is mounted, or asked
  for its passphrase, twice.
- A mounted drive has an eject button: removable ones are ejected, others
  unmounted. Panes in a drive that goes away, from here or elsewhere, go
  home first.
- An encrypted drive that unlocks with nothing mountable inside says so,
  instead of nothing happening.
A wrong passphrase and a retry left the first reply's timer running, so
it could cancel the corrected attempt early. A new request now stops the
last reply's timer, and each reply starts its own.
An encrypted drive that unlocked but was slow to mount its filesystem
still read as "nothing on it that can be mounted" once the minute ran
out. Now that's said only when nothing inside the unlocked device is a
filesystem, by udev's record of it; otherwise it's reported as timed out.
Main now lets go of mounted drives itself (Places::eject and leave, the
drive menu and its eject button), so the branch keeps only what main
lacks: GIO's unmounted volumes in Devices, mounting one with its
passphrase put in the window, and mounting a drive as it's plugged in.
A drive's questions go to the user, as an unverified server's do, and an
unmount from anywhere is left through Places::leave.
Comment thread src/places.cpp Resolved
@AyushKr2003 AyushKr2003 changed the title List drives that aren't mounted yet, and mount and eject them List drives that aren't mounted yet, and mount them on a click or as they're plugged in Nov 12, 2026
@amagdy46

Copy link
Copy Markdown

I built much the same thing locally before finding this, so I'll leave drives to this PR. Two things from mine that might be worth folding in:

  • A mounted drive with no label is named after its mount folder, which for udisks is the UUID (8CAE187EAE18634E). g_mount_get_name gives "1.0 TB Volume", matching the unmounted rows.
  • The eject button is easy to miss when it only appears on hover. Keeping it at the end of every row that can be let go of, as Nautilus does, made it discoverable.

@omarchybot omarchybot added the enhancement New feature or request label Nov 15, 2026
# Conflicts:
#	src/main.cpp
Comment thread src/backend.cpp Resolved
Comment thread src/drives.cpp Resolved
@greptile-apps

greptile-apps Bot commented Nov 17, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

# Conflicts:
#	src/Sidebar.qml
#	src/i18n/en.json
Comment thread src/places.cpp Resolved
Comment thread src/mounter.cpp Resolved
dhh and others added 2 commits November 18, 2026 15:29
…losed window's mount

A drive plugged in or mounted while the mounts were still being read
(an NFS mount that stopped answering, say) waited for that unrelated
reading to finish before it showed in Devices, even an unmounted drive
that needs no filesystem read at all. The Devices list is now made
again from GIO's volumes and the last finished reading as soon as GIO
says something changed; what's free on a new drive fills in with the
next reading.

A window closed after a drive's passphrase went in dropped its mount's
cancellable without cancelling it, and the minute-long timer went with
the window, so a drive that unlocked with nothing to mount inside left
GVfs's mount pending for good. The window now cancels it on its way out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/drives.cpp Resolved
A drive plugged in is left two seconds to the desktop's own automounter
(udiskie, a shell) and mounted by Folio if it's still unmounted then.
For an encrypted drive that's no sign the other one is done: it can
still be waiting on its passphrase, and Folio would ask for it a second
time. An encrypted drive is now never mounted as it's plugged in; it
shows in Devices and mounts, asking once, on a click.

What udev found on a device is read in one place, Drives::usageOf,
which the Mounter's check for a drive that unlocked with nothing to
mount inside now uses too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhh

dhh commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Before/after of the sidebar on today's main (this branch merged locally onto it). Real drives can't be faked offscreen, so both sides are fed the same made-up machine: three partitions that aren't mounted (Acer, 53 GB Volume, ryoku) and a mounted TESTSTICK. Main lists Devices from Places::physicalDrives over the mounts, so only the stick; this branch's Places::devicesFrom over the same mounts plus GIO-style volumes lists the unmounted partitions too, with no free space or eject button until they're mounted.

Before and after: Devices lists the unmounted partitions above the mounted stick

An unmounted drive has no path, so it matched a folder under no row (Home
itself), and Tab landed on the last drive.
Comment thread src/places.cpp Outdated
Comment on lines +445 to +447
for (const QVariant &drive : drives)
if (!listed.contains(drive.toMap().value("path").toString()))
devices << drive;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Unmounted drives keep old rows

If readMounts() is stalled when a drive is unmounted, devicesFrom() adds its new unmounted row, then appends the old mounted row from m_lastMounts. A removed drive also keeps its old row. Clicking that stale row opens the old mount folder instead of mounting the drive, and the row remains until the stalled read finishes.

Exclude cached rows for volumes GIO now reports as unmounted or removed, while preserving mounts GIO does not manage.

Knowledge Base Used: Storage discovery and mounts

While a mount reading is stalled, Devices is built from the last one. A
drive unmounted since then got its unmounted row and its old mounted row
too, and one pulled out kept its row; clicking either opened a folder
that was no longer the drive's. A drive whose device GIO now lists
unmounted, or whose device node is gone, is left out; mounts GIO doesn't
manage stay.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants