PHP Class HM\BackUpWordPress\Site_Size

Use to calculate the total or partial size of the sites database and files.
Datei anzeigen Open project: humanmade/backupwordpress

Public Methods

Method Description
__construct ( string $type = 'complete', Excludes $excludes = null ) Constructor
directory_filesize ( SplFileInfo $file )
filesize ( SplFileInfo $file ) : integer Get the total filesize for a given file or directory. Aware of exclusions.
get_cached_filesizes ( $max_age = WEEK_IN_SECONDS )
get_formatted_site_size ( ) : string Get the site size formatted
get_site_size ( ) : string Calculate the size total size of the database + files.
is_site_size_being_calculated ( ) : boolean Whether the total filesize is being calculated
is_site_size_cached ( ) : boolean Whether the total filesize is cached
rebuild_directory_filesizes ( )
recursive_filesize_scanner ( ) : array Recursively scans a directory to calculate the total filesize

Method Details

__construct() public method

Set up some initial conditions including whether we want to calculate the size of the database, files or both and whether to exclude any files from the file size calculation.
public __construct ( string $type = 'complete', Excludes $excludes = null )
$type string Whether to calculate the size of the database, files or both. Should be one of 'file', 'database' or 'complete'
$excludes Excludes An array of exclude rules

directory_filesize() public method

public directory_filesize ( SplFileInfo $file )
$file SplFileInfo

filesize() public method

If $file is a file then return the result of filesize() or 0 if it's excluded. If $file is a directory then recursively calculate the size without the size of excluded files/directories.
public filesize ( SplFileInfo $file ) : integer
$file SplFileInfo The file or directory you want to know the size of.
return integer The total filesize of the file or directory without the size of excluded files/directories.

get_cached_filesizes() public method

public get_cached_filesizes ( $max_age = WEEK_IN_SECONDS )

get_formatted_site_size() public method

Get the site size formatted
See also: size_format
public get_formatted_site_size ( ) : string
return string

get_site_size() public method

Doesn't account for any compression that would be gained by zipping.
public get_site_size ( ) : string
return string

is_site_size_being_calculated() public static method

Whether the total filesize is being calculated
public static is_site_size_being_calculated ( ) : boolean
return boolean

is_site_size_cached() public method

Whether the total filesize is cached
public is_site_size_cached ( ) : boolean
return boolean

rebuild_directory_filesizes() public method

recursive_filesize_scanner() public method

Locks should be set by the caller with set_transient( 'hmbkp_directory_filesizes_running', true, HOUR_IN_SECONDS );
public recursive_filesize_scanner ( ) : array
return array $directory_sizes An array of directory paths => filesize sum of all files in directory