protected function calculateTotalSize(Node $node)
 {
     $size = $node['contentProperties']['size'] ?: 0;
     if ($node->isFolder() || $this->input->getOption('assets')) {
         foreach ($node->getChildren() as $child) {
             $size += $this->calculateTotalSize($child);
         }
     }
     return $size;
 }
Example #2
0
 protected function buildMarkdownTree(Node $node, $includeAssets = false, $prefix = '')
 {
     static $first;
     if (is_null($first)) {
         $first = false;
         if ($node->isFolder()) {
             $this->output->writeln("<blue>{$node['name']}</blue>");
         } else {
             $this->output->writeln($node['name']);
         }
     }
     foreach ($node->getChildren() as $node) {
         $this->output->writeln("{$prefix}- {$node['name']}");
         if ($node->isFolder() || $includeAssets === true) {
             $this->buildMarkdownTree($node, $includeAssets, "{$prefix}  ");
         }
     }
 }
Example #3
0
 /**
  * Move a FILE or FOLDER `Node` to a new remote location.
  *
  * @param \CloudDrive\Node $newFolder
  *
  * @return array
  * @throws \Exception
  */
 public function move(Node $newFolder)
 {
     if (!$newFolder->isFolder()) {
         throw new \Exception("New destination node is not a folder.");
     }
     if (!$this->isFile() && !$this->isFolder()) {
         throw new \Exception("Moving a node can only be performed on FILE and FOLDER kinds.");
     }
     $retval = ['success' => false, 'data' => []];
     $response = self::$httpClient->post(self::$account->getMetadataUrl() . "nodes/{$newFolder['id']}/children", ['headers' => ['Authorization' => 'Bearer ' . self::$account->getToken()['access_token']], 'json' => ['fromParent' => $this['parents'][0], 'childId' => $this['id']], 'exceptions' => false]);
     $retval['data'] = json_decode((string) $response->getBody(), true);
     if ($response->getStatusCode() === 200) {
         $retval['success'] = true;
         $this->replace($retval['data']);
         $this->save();
     }
     return $retval;
 }