Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a06dc96

Browse files
author
Ned Zimmerman
authoredOct 11, 2018
Handle symlinked directories (#13)
* Handle symlinked directories In Trellis systems, the uploads directory is a symlink, so we need to use realpath() to resolve the symlink to ensure that we get an accurate directory size. * Use escapeshellarg
1 parent 7b94ab4 commit a06dc96

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎inc/stats/namespace.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,9 @@ function display_network_storage() {
492492
}
493493

494494
function calculate_network_storage() {
495-
$path = wp_upload_dir()['basedir'];
496-
$storage = format_bytes( rtrim( str_replace( $path, '', `du -b -s $path` ) ) );
495+
$path = realpath( wp_upload_dir()['basedir'] );
496+
$output = exec( sprintf( 'du -b -s %s', escapeshellarg( $path ) ) );
497+
$storage = format_bytes( rtrim( str_replace( $path, '', $output ) ) );
497498
return $storage;
498499
}
499500

0 commit comments

Comments
 (0)
Please sign in to comment.