Commit c3c6d186 authored by jpetrell's avatar jpetrell

[storage] Notify view side when available space in partition changes during manual model refresh()

parent 254ef0d8
...@@ -229,7 +229,7 @@ void PartitionManagerPrivate::refresh() ...@@ -229,7 +229,7 @@ void PartitionManagerPrivate::refresh()
const auto removedPartitions = m_partitions.mid(index); const auto removedPartitions = m_partitions.mid(index);
m_partitions.resize(index); m_partitions.resize(index);
refresh(m_partitions); refresh(m_partitions, changedPartitions);
for (const auto partition : removedPartitions) { for (const auto partition : removedPartitions) {
emit partitionRemoved(Partition(partition)); emit partitionRemoved(Partition(partition));
...@@ -249,12 +249,12 @@ void PartitionManagerPrivate::refresh() ...@@ -249,12 +249,12 @@ void PartitionManagerPrivate::refresh()
void PartitionManagerPrivate::refresh(PartitionPrivate *partition) void PartitionManagerPrivate::refresh(PartitionPrivate *partition)
{ {
refresh(Partitions() << QExplicitlySharedDataPointer<PartitionPrivate>(partition)); refresh(Partitions() << QExplicitlySharedDataPointer<PartitionPrivate>(partition), Partitions() << QExplicitlySharedDataPointer<PartitionPrivate>(partition));
emit partitionChanged(Partition(QExplicitlySharedDataPointer<PartitionPrivate>(partition))); emit partitionChanged(Partition(QExplicitlySharedDataPointer<PartitionPrivate>(partition)));
} }
void PartitionManagerPrivate::refresh(const Partitions &partitions) void PartitionManagerPrivate::refresh(const Partitions &partitions, Partitions &changedPartitions)
{ {
for (auto partition : partitions) { for (auto partition : partitions) {
// Reset properties to the unmounted defaults. If the partition is mounted these will be restored // Reset properties to the unmounted defaults. If the partition is mounted these will be restored
...@@ -311,11 +311,20 @@ void PartitionManagerPrivate::refresh(const Partitions &partitions) ...@@ -311,11 +311,20 @@ void PartitionManagerPrivate::refresh(const Partitions &partitions)
if (partition->status == Partition::Mounted) { if (partition->status == Partition::Mounted) {
struct statvfs64 stat; struct statvfs64 stat;
if (::statvfs64(partition->mountPath.toUtf8().constData(), &stat) == 0) { if (::statvfs64(partition->mountPath.toUtf8().constData(), &stat) == 0) {
partition->bytesTotal = stat.f_blocks * stat.f_frsize; partition->bytesTotal = stat.f_blocks * stat.f_frsize;
partition->bytesFree = stat.f_bfree * stat.f_frsize; qint64 bytesFree = stat.f_bfree * stat.f_frsize;
partition->bytesAvailable = stat.f_bavail * stat.f_frsize; qint64 bytesAvailable = stat.f_bavail * stat.f_frsize;
partition->readOnly = (stat.f_flag & ST_RDONLY) != 0; partition->readOnly = (stat.f_flag & ST_RDONLY) != 0;
if (partition->bytesFree != bytesFree || partition->bytesAvailable != bytesAvailable) {
if (!changedPartitions.contains(partition)) {
changedPartitions.append(partition);
}
}
partition->bytesFree = bytesFree;
partition->bytesAvailable = bytesAvailable;
} }
} else if (partition->storageType == Partition::External) { } else if (partition->storageType == Partition::External) {
// Presume the file system can be mounted, unless we can confirm otherwise. // Presume the file system can be mounted, unless we can confirm otherwise.
......
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
void refresh(); void refresh();
void refresh(PartitionPrivate *partition); void refresh(PartitionPrivate *partition);
void refresh(const Partitions &partitions); void refresh(const Partitions &partitions, Partitions &changedPartitions);
signals: signals:
void partitionChanged(const Partition &partition); void partitionChanged(const Partition &partition);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment