Skip to content

Commit

Permalink
Linux: do not re-create drives on PropertiesChanged signal from Udisk…
Browse files Browse the repository at this point in the history
…s2 (#650)

Resolves #640
  • Loading branch information
grulja authored and gastoner committed Oct 7, 2023
1 parent 6fcc120 commit 986fc6a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/app/drivemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ Progress *Drive::progress() const
return m_progress;
}

void Drive::updateDrive(const QString &name, uint64_t size, bool containsLive)
{
m_name = name;
m_size = size;
setRestoreStatus(containsLive ? CONTAINS_LIVE : CLEAN);
}

QString Drive::name() const
{
return QString("%1 (%2)").arg(m_name).arg(readableSize());
Expand Down
2 changes: 2 additions & 0 deletions src/app/drivemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class Drive : public QObject

Progress *progress() const;

virtual void updateDrive(const QString &name, uint64_t size, bool containsLive = false);

virtual QString name() const;
virtual QString readableSize() const;
virtual qreal size() const;
Expand Down
6 changes: 3 additions & 3 deletions src/app/linuxdrivemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ QDBusObjectPath LinuxDriveProvider::handleObject(const QDBusObjectPath &object_p
mDebug() << this->metaObject()->className() << "New drive" << driveId.path() << "-" << name << "(" << size << "bytes;" << (isValid ? "removable;" : "nonremovable;") << connectionBus << ")";

if (isValid) {
// TODO find out why do I do this
if (m_drives.contains(object_path)) {
LinuxDrive *tmp = m_drives[object_path];
emit DriveProvider::driveRemoved(tmp);
m_drives[object_path]->updateDrive(name, size, isoLayout);
return object_path;
}

LinuxDrive *d = new LinuxDrive(this, object_path.path(), name, size, isoLayout);
m_drives[object_path] = d;
emit DriveProvider::driveConnected(d);
Expand Down

0 comments on commit 986fc6a

Please sign in to comment.