More code standards
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@ -9,7 +9,13 @@ use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Wrapper for the rclone command line utility
|
||||
*
|
||||
* Installation of rclone is required.
|
||||
* Configuration of the mounts must be done before use.
|
||||
* Tested using rclone v1.53.3-DEV
|
||||
*/
|
||||
class Rclone
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
@ -24,6 +30,14 @@ class Rclone
|
||||
|
||||
protected string $version = "";
|
||||
|
||||
/**
|
||||
* Create a new instance
|
||||
*
|
||||
* Default it looks for "rclone" on the path.
|
||||
* But the path can be configured to be absolute.
|
||||
*
|
||||
* @param string $rclonePath Relative or absolute path
|
||||
*/
|
||||
function __construct(string $rclonePath = "rclone")
|
||||
{
|
||||
$this->rclonePath = $rclonePath;
|
||||
@ -44,17 +58,35 @@ class Rclone
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rclone version
|
||||
*
|
||||
* @return string Version string
|
||||
*/
|
||||
function getVersion(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the size of a mount/path
|
||||
*
|
||||
* @return int Size in bytes
|
||||
*/
|
||||
function getSize(string $path): int
|
||||
{
|
||||
$output = $this->exec('size', ['--json', $path]);
|
||||
return (int)json_decode($output)->bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy from src to dest
|
||||
*
|
||||
* @param $src Source mount and path
|
||||
* @param $dest Destination mount and path
|
||||
* @param $bandwidth Bandwidth limit provided as string
|
||||
* @return string Stdout from command
|
||||
*/
|
||||
function copy(string $src, string $dest, string $bandwidth = null): string
|
||||
{
|
||||
$options = array();
|
||||
|
Reference in New Issue
Block a user