Documentation

DirectorySync

DirectorySync upload class, in charge of creating, replacing and delete data objects on the API. The goal of this execution is to sync local directories with remote CloudFiles containers so that they are consistent.

Table of Contents

$basePath  : string
$container  : AbstractContainer
$remoteFiles  : ResourceIterator
$targetDir  : string
execute()  : mixed
Execute the sync process. This will collect all the remote files from the API and do a comparison. There are four scenarios that need to be dealt with:
factory()  : DirectorySync
Basic factory method to instantiate a new DirectorySync object with all the appropriate properties.
setBasePath()  : mixed
setContainer()  : mixed
setRemoteFiles()  : mixed
setTargetDir()  : mixed
getCallback()  : callable
Get the callback used to do a search function on the remote iterator.
traversePath()  : array<string|int, mixed>
Given a path, traverse it recursively for nested files.
trimFilename()  : string
Given a path, trim away leading slashes and strip the base path.

Properties

$basePath

private string $basePath

The path to the directory you're syncing.

$container

private AbstractContainer $container

The Container object you are syncing.

Methods

execute()

Execute the sync process. This will collect all the remote files from the API and do a comparison. There are four scenarios that need to be dealt with:

public execute() : mixed
  • Exists locally, exists remotely (identical checksum) = no action
  • Exists locally, exists remotely (diff checksum) = local overwrites remote
  • Exists locally, not exists remotely = local is written to remote
  • Not exists locally, exists remotely = remote file is deleted
Return values
mixed

factory()

Basic factory method to instantiate a new DirectorySync object with all the appropriate properties.

public static factory(string $path, Container $container[, string $targetDir = null ]) : DirectorySync
Parameters
$path : string

The local path

$container : Container

The container you're syncing

$targetDir : string = null

The path (or pseudo-directory) that the files will be nested in

Return values
DirectorySync

setTargetDir()

public setTargetDir(string $dir) : mixed
Parameters
$dir : string

The target path that all files will be nested in. By default, the files will not be nested.

Return values
mixed

getCallback()

Get the callback used to do a search function on the remote iterator.

private getCallback( $name) : callable
Parameters
$name :

The name of the file we're looking for.

Return values
callable

traversePath()

Given a path, traverse it recursively for nested files.

private traversePath( $path) : array<string|int, mixed>
Parameters
$path :
Return values
array<string|int, mixed>

trimFilename()

Given a path, trim away leading slashes and strip the base path.

private trimFilename( $file) : string
Parameters
$file :
Return values
string

Search results