GNOME Bugzilla – Bug 313668
Nautilus Properties incorrectly totals sizes of hardlinked files
Last modified: 2008-05-23 17:40:13 UTC
This bug has been opened here: https://bugzilla.ubuntu.com/show_bug.cgi?id=12519 "I have a baz revision library, and wanted to know how much disk space it is taking up. I right-clicked on the directory using nautilus and went to properties. It came up with a total filesize of 40.2 GB. 'du -s' on the other hand reported about 4 GB. Lots of files in the revision library are hardlinked together - hence nautilus is naively adding the file sizes together instead of noting which files occupy the same space."
Thanks for your bug report! This is indeed very ugly. The relevant code is in libnautilus-private/nautilus-directory-async.c. We seem to do this wrong for symlinks as well. Technically, there is no way to detect that we have a hardlinks except by comparing the inodes of all scanned files, right?
In baobab ( http://www.marzocca.net/linux/baobab.html ) I am handling hardlinks this way: when the user starts a full disk scan, baobab sets up an array of hardlinks (by comparing inodes). Then, the first hardlink is counted as a normal file, while the subsequent links to the same inode device are not counted in the total, but highlighted in the right-hand column of the window.
*** Bug 332069 has been marked as a duplicate of this bug. ***
I was coming to report the very same bug. Except that now we are using Gnome 2.20 and soon 2.22. The proposed solution in comment #2 seems elegant, at least I would have used this logic in another context. If I set a patch implementing this solution, would it have any chance to be accepted? For Gnome 2.24 now I guess.
Patches are very welcome, please do.
I committed a fix to trunk and to the GNOME 2.22 branch: http://svn.gnome.org/viewvc/nautilus?view=revision&revision=14189 http://svn.gnome.org/viewvc/nautilus?view=revision&revision=14190 The hardlinks will be counted as objects, but the size will just be counted once. Closing as fixed.