Amazon_S3_And_CloudFront::multisite_get_spaced_used PHP Method

multisite_get_spaced_used() public method

Used to give a realistic total of storage space used on a Multisite subsite, when there have been attachments uploaded to S3 but removed from server
public multisite_get_spaced_used ( $space_used ) : float | integer
$space_used bool
return float | integer
    function multisite_get_spaced_used($space_used)
    {
        global $wpdb;
        // Sum the total file size (including image sizes) for all S3 attachments
        $sql = "SELECT SUM( meta_value ) AS bytes_total\n\t\t\t\tFROM {$wpdb->postmeta}\n\t\t\t\tWHERE meta_key = 'wpos3_filesize_total'";
        $space_used = $wpdb->get_var($sql);
        // Get local upload sizes
        $upload_dir = wp_upload_dir();
        $space_used += get_dirsize($upload_dir['basedir']);
        if ($space_used > 0) {
            // Convert to bytes to MB
            $space_used = $space_used / 1024 / 1024;
        }
        return $space_used;
    }
Amazon_S3_And_CloudFront