Bug 193298 - Wrong free disk space displayed when directory beginn with the same name
Summary: Wrong free disk space displayed when directory beginn with the same name
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: bars: status (show other bugs)
Version: 2.1
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords: investigated, triaged
Depends on:
Blocks:
 
Reported: 2009-05-19 23:50 UTC by Thomas Thym
Modified: 2013-04-28 20:22 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.10.3
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Thym 2009-05-19 23:50:25 UTC
Version:            (using KDE 4.2.85)
OS:                Linux
Installed from:    SuSE RPMs

After mounting a new partition (19GiB free) at ~/Videos the original dir ~/Videos-Home (subdir of /home) shows the wrong free disk space (19 GiB) instead of 8 GiB.

When I rename the old dir from Videos-Home to another name, where the second dirname "Videos" is not part of (e.g. Video-Home, without the "s") the size is displayed korrectly.

It's not a hi-priority bug. Just wanted to report it.
Comment 1 Jekyll Wu 2012-08-17 07:27:59 UTC
Still reproducing using dolphin 2.1 . 

To make the report clear, the two folders are "~/Videos"(the mount point) and "~/Videos-Home" . Actually, the same problem can be reproduced using "~/book" ( the mount point) and "~/books" (a empty folder) .
Comment 2 Jekyll Wu 2012-08-17 12:32:25 UTC
This is actually a bug of kdelibs. 

in kdelibs/kio/kfile/kdiskfreespaceinfo.cpp

KDiskFreeSpaceInfo KDiskFreeSpaceInfo::freeSpaceInfo( const QString& path )
{
    ...
    KMountPoint::Ptr mp = KMountPoint::currentMountPoints().findByPath( path );
    ...
}

in kdelibs/kdecore/io/kmountpoint.cpp

KMountPoint::Ptr KMountPoint::List::findByPath(const QString& path) const
{
    ...

    int max = 0;
    KMountPoint::Ptr result;
    for (const_iterator it = begin(); it != end(); ++it) {
        const QString mountpoint = (*it)->d->mountPoint;
        const int length = mountpoint.length();
        if (realname.startsWith(mountpoint) && length > max) {
            max = length;
            result = *it;
            // keep iterating to check for a better match (bigger max)
        }
    }
}

So if "/home/myself/book" is a mount point, "/home/myself/books" will be seen as 
belonging to the partition mounted at "/home/myself/book", which is clearly wrong.
Comment 3 Jeroen van Meeuwen (Kolab Systems) 2012-08-24 16:19:43 UTC
Resetting assignee to default as per bug #305719
Comment 4 Frank Reininghaus 2012-11-06 07:24:19 UTC
Good investigation, Jekyll! Maybe one could solve this by using KUrl::isParentOf(const KUrl&), rather than QString:.startsWith(const QString&)?
Comment 5 Frank Reininghaus 2013-04-28 20:22:14 UTC
Git commit 4f2ecbabfa5bec07985175798ea20d90bdca9f82 by Frank Reininghaus.
Committed on 28/04/2013 at 22:19.
Pushed by freininghaus into branch 'KDE/4.10'.

Fix KMountPoint::List::findByPath(): /books is not a child of /book

Thanks to Jekyll Wu for the analysis and to David Faure for pointing out
another problem which I had missed.
FIXED-IN: 4.10.3
REVIEW: 110225

M  +20   -1    kdecore/io/kmountpoint.cpp

http://commits.kde.org/kdelibs/4f2ecbabfa5bec07985175798ea20d90bdca9f82