mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-23 16:01:43 +01:00
giolister: Ignore mountpoints
Read the G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT attribute (unix::is-mountpoint) to determine if a volume is a mount that udisks2 has detected. Ignoring these prevents network mounts from showing up as devices.
This commit is contained in:
parent
f5c904b267
commit
cca48b1ebf
@ -44,6 +44,8 @@ QString GioLister::DeviceInfo::unique_id() const {
|
||||
bool GioLister::DeviceInfo::is_suitable() const {
|
||||
if (!volume_) return false; // This excludes smb or ssh mounts
|
||||
|
||||
if (is_mountpoint) return false; // Exclude mounts from fstab, etc
|
||||
|
||||
if (drive_ && !drive_removable)
|
||||
return false; // This excludes internal drives
|
||||
|
||||
@ -254,7 +256,10 @@ void GioLister::VolumeAdded(GVolume* volume) {
|
||||
#endif
|
||||
info.ReadDriveInfo(g_volume_get_drive(volume));
|
||||
info.ReadMountInfo(g_volume_get_mount(volume));
|
||||
if (!info.is_suitable()) return;
|
||||
if (!info.is_suitable()) {
|
||||
qLog(Debug) << "Skipping" << info.volume_name;
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
QMutexLocker l(&mutex_);
|
||||
@ -289,7 +294,10 @@ void GioLister::MountAdded(GMount* mount) {
|
||||
#endif
|
||||
info.ReadMountInfo(mount);
|
||||
info.ReadDriveInfo(g_mount_get_drive(mount));
|
||||
if (!info.is_suitable()) return;
|
||||
if (!info.is_suitable()) {
|
||||
qLog(Debug) << "Skipping" << info.volume_name;
|
||||
return;
|
||||
}
|
||||
|
||||
QString old_id;
|
||||
{
|
||||
@ -430,19 +438,24 @@ void GioLister::DeviceInfo::ReadMountInfo(GMount* mount) {
|
||||
}
|
||||
|
||||
// Query the file's info for a filesystem ID
|
||||
// Only afc devices (that I know of) give reliably unique IDs
|
||||
if (filesystem_type == "afc") {
|
||||
error = nullptr;
|
||||
info = g_file_query_info(root, G_FILE_ATTRIBUTE_ID_FILESYSTEM,
|
||||
G_FILE_QUERY_INFO_NONE, nullptr, &error);
|
||||
if (error) {
|
||||
qLog(Warning) << QString::fromLocal8Bit(error->message);
|
||||
g_error_free(error);
|
||||
} else {
|
||||
error = nullptr;
|
||||
info = g_file_query_info(root,
|
||||
G_FILE_ATTRIBUTE_ID_FILESYSTEM
|
||||
"," G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT,
|
||||
G_FILE_QUERY_INFO_NONE, nullptr, &error);
|
||||
if (error) {
|
||||
qLog(Warning) << QString::fromLocal8Bit(error->message);
|
||||
g_error_free(error);
|
||||
} else {
|
||||
is_mountpoint = g_file_info_get_attribute_boolean(
|
||||
info, G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT);
|
||||
|
||||
// Only afc devices (that I know of) give reliably unique IDs
|
||||
if (filesystem_type == "afc") {
|
||||
mount_uuid = QString::fromUtf8(g_file_info_get_attribute_string(
|
||||
info, G_FILE_ATTRIBUTE_ID_FILESYSTEM));
|
||||
g_object_unref(info);
|
||||
}
|
||||
g_object_unref(info);
|
||||
}
|
||||
|
||||
g_object_unref(root);
|
||||
|
@ -67,6 +67,7 @@ class GioLister : public DeviceLister {
|
||||
: drive_removable(false),
|
||||
filesystem_size(0),
|
||||
filesystem_free(0),
|
||||
is_mountpoint(false),
|
||||
invalid_enclosing_mount(false) {}
|
||||
|
||||
QString unique_id() const;
|
||||
@ -104,6 +105,8 @@ class GioLister : public DeviceLister {
|
||||
quint64 filesystem_free;
|
||||
QString filesystem_type;
|
||||
|
||||
bool is_mountpoint; // unix::is-mountpoint
|
||||
|
||||
bool invalid_enclosing_mount;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user