예제 #1
0
 /**
  * @param   Garp_Content_Upload_FileList $thoseFiles    The file list to check for corresponding files
  * @return  Garp_Content_Upload_FileList                Files that are unique and do not exist in $thoseFiles
  */
 public function findUnique(Garp_Content_Upload_FileList $thoseFiles)
 {
     $unique = new Garp_Content_Upload_FileList();
     foreach ($this as $thisFile) {
         if (!$thoseFiles->nodeExists($thisFile)) {
             $unique->addEntry($thisFile);
         }
     }
     return $unique;
 }
예제 #2
0
파일: S3.php 프로젝트: grrr-amsterdam/garp3
 /**
  * @param Array     $dirList    Array of file paths
  * @param String    $type       Upload type
  */
 protected function _findFilesByType(array $dirList, $type)
 {
     $fileList = new Garp_Content_Upload_FileList();
     foreach ($dirList as $path) {
         if ($this->_isFilePath($path) && $this->_isAllowedPath($path)) {
             $baseName = basename($path);
             $fileNode = new Garp_Content_Upload_FileNode($baseName, $type);
             $fileList->addEntry($fileNode);
         }
     }
     return $fileList;
 }
예제 #3
0
 /**
  * @return Garp_Content_Upload_FileList
  */
 public function fetchFileListByType($type, $relDir)
 {
     $fileList = new Garp_Content_Upload_FileList();
     $baseDir = $this->_getBaseDir();
     $lsCommand = "ls -ogl {$baseDir}{$relDir}";
     $session = $this->getSshSession();
     $stream = ssh2_exec($session, $lsCommand);
     $dirListing = $this->_fetchAndCloseStream($stream) . "\n";
     $matches = array();
     $pattern = '/(?P<permissions>[drwx\\-+@]+)\\s+\\d+\\s+(?P<filesize>\\d+)\\s+(?P<lastmodified>\\w{3}\\s+\\d+\\s+\\d+:?\\d+)\\s+(?P<filename>[^ \\n]+)\\n+/';
     preg_match_all($pattern, $dirListing, $matches);
     foreach ($matches['permissions'] as $index => $permission) {
         $fileName = $matches['filename'][$index];
         if ($permission[0] !== 'd' && $this->_isAllowedPath($fileName)) {
             $fileNode = new Garp_Content_Upload_FileNode($fileName, $type);
             $fileList->addEntry($fileNode);
         }
     }
     return $fileList;
 }
예제 #4
0
 /**
  * @param Array     $dirList    Array of filenames, f.i. the result of php's scandir()
  * @param String    $type       Upload type
  * @return Garp_Content_Upload_FileList
  */
 protected function _addFilesByType(array $dirList, $type)
 {
     $fileList = new Garp_Content_Upload_FileList();
     foreach ($dirList as $baseName) {
         $absPath = $this->_getAbsPath($baseName, $type);
         if (is_file($absPath)) {
             $fileNode = new Garp_Content_Upload_FileNode($baseName, $type);
             $fileList->addEntry($fileNode);
         }
     }
     return $fileList;
 }
예제 #5
0
 /**
  * @param   Garp_Content_Upload_FileList    &$conflictsByEtag   A reference to the list that a matching entry should be added to
  * @param   Garp_Content_Upload_FileNode    $file   The current file node within the Garp_Content_Upload_FileList
  * @return  Void
  */
 protected function _addEtagConflictingFile(Garp_Content_Upload_FileList &$conflictsByEtag, Garp_Content_Upload_FileNode $file)
 {
     $progress = Garp_Cli_Ui_ProgressBar::getInstance();
     $filename = $file->getFilename();
     $progress->display("Comparing {$filename}");
     if (!$this->_matchEtags($file)) {
         $conflictsByEtag->addEntry($file);
     }
     $progress->advance();
 }