Example #1
0
$pathError = Dropbox\Path::findError($bloc->path);
if ($pathError !== null) {
	throw new CHttpException(500, "Invalid <dropbox-path>: $pathError\n");
}
*/
// Getting metadata from db if not changed, otherwise getting from request and updating db.
if ($bloc->previous_folder_hash == '') {
    $metadata = $client->getMetadataWithChildren($bloc->path);
    if ($metadata === null) {
        //throw new CHttpException(500, "No file or folder at that path.\n");
    }
    $bloc->previous_folder_hash = $metadata['hash'];
    $bloc->previous_folder = serialize($metadata);
    $bloc->save(false);
} else {
    $metadata = $client->getMetadataWithChildrenIfChanged($bloc->path, $bloc->previous_folder_hash);
    if ($metadata[0] == true) {
        if ($metadata[1] === null) {
            //throw new CHttpException(500, "No file or folder at that path.\n");
        }
        $metadata = $metadata[1];
        $bloc->previous_folder_hash = $metadata['hash'];
        $bloc->previous_folder = serialize($metadata);
        $bloc->save(false);
    } else {
        $metadata = unserialize($bloc->previous_folder);
    }
}
// If it's a folder, remove the 'contents' list from $metadata; print that stuff out after.
$children = null;
if ($metadata['is_dir']) {