Don't count hard-links multiple times

Version 1.52

Bugfix
Finished

For the "Email Disk Usage" count, DA includes various areas, including: /home/user/imap /home/user/Maildir which are files managed by Dovecot. Dovecot often uses hard-links when copying messages around to save space, but when DA previously counted the disk usage, the same file might get counted many times. This changes is to still count the same file multiple times, but if it's owned by the User and has multiple hard links, divide that file's current size by the number of hard links. So if a file has 2 links, DA counts 1/2 the size twice, giving a more accurate result. Note that this will not affect the total disk usage, which relies on the System Quotas, a completely different system. This change will just make the results closer to the "du" output, which handles multiple hard-links in a different way (likely tracking all of their IDs in a hash) but should arrive at the same result as long as the files are under the same path (which is why this is only done for specific dovecot paths) This will also *not* affect the File Manager directory usage output for the above folders, so for example, the results you'll see for /home/user/imap will probably be different than the total that DA gets during the tally.

Interested to try DirectAdmin? Get a 30-day Free Trial!