Fix: Recursively calculate directory size in `size_of_dir`
Fixed size_of_dir_entry to recursively calculate the size of directories. Previously, the function only returned the metadata size of directory entries (typically a few KB), completely ignoring files within subdirectories. This caused size_of_dir to return incorrect sizes for any directory tree with nested folders.
The fix checks if an entry is a directory and recursively calls size_of_dir to sum up all file sizes within the directory tree.
Please rebase your change on unstable.
@maradini77 Do you have any thoughts on the above?
@michaelsproul Thanks for the careful review. Agreed: symlinks won’t cause an infinite loop because is_dir is false on them. I added recursion to avoid hidden bugs if the data directory ever stops being flat (e.g., future tools/plugins). To reduce DoS risk from deep nesting, I can switch to an iterative walk with a depth/entry cap and skip symlinks. Would you be comfortable if I add those protections?
@maradini77 Yeah let's make it iterative and capped, sounds good!
@maradini77 Yeah let's make it iterative and capped, sounds good!
@michaelsproul updated
Some required checks have failed. Could you please take a look @maradini77? 🙏
@michaelsproul fmt fuxed