コード例 #1
0
ファイル: Photo.php プロジェクト: fulldecent/cameralife
 /**
  * isCacheMissing function.
  * Return true if thumbnail is missing or if needed _mod is missing
  *
  * @access public
  * @return bool
  */
 public function isCacheMissing()
 {
     if ($this->record['modified'] == '1') {
         return true;
         //legacy before 2.7
     }
     $cacheBucket = FileStore::fileStoreWithName('other');
     if ($this->record['modified']) {
         $filename = '/' . $this->record['id'] . '_mod.' . $this->extension;
         $stat = $cacheBucket->listFiles($filename);
         if (!count($stat)) {
             return true;
         }
     }
     $sizes = array();
     $sizes[] = Preferences::valueForModuleWithKey('CameraLife', 'thumbsize');
     $sizes[] = Preferences::valueForModuleWithKey('CameraLife', 'scaledsize');
     $options = Preferences::valueForModuleWithKey('CameraLife', 'optionsizes');
     preg_match_all('/[0-9]+/', $options, $matches);
     $sizes = array_merge($sizes, $matches[0]);
     foreach ($sizes as $cursize) {
         $filename = '/' . $this->record['id'] . '_' . $cursize . '.' . $this->extension;
         $stat = $cacheBucket->listFiles($filename);
         if (!count($stat)) {
             return true;
         }
     }
     return false;
 }
コード例 #2
0
ファイル: Folder.php プロジェクト: fulldecent/cameralife
 /**
  * Does a quick compare of Database and FileStore and checks if they are same
  *
  * @return true or false
  */
 public function fsck()
 {
     $fileStore = FileStore::fileStoreWithName('photo');
     $fileStoreNewPhotos = $fileStore->listFiles();
     // path->basename format
     if (!count($fileStoreNewPhotos)) {
         throw new \Exception('No files were found in file store');
     }
     $result = Database::select('photos', 'id,filename,path,fsize', 'status!=9', 'ORDER BY path,filename');
     // Verify each photo in the DB
     while ($dbPhoto = $result->fetchAssoc()) {
         $dbFilePath = rtrim('/' . ltrim($dbPhoto['path'], '/'), '/') . '/' . $dbPhoto['filename'];
         if (isset($fileStoreNewPhotos[$dbFilePath])) {
             unset($fileStoreNewPhotos[$dbFilePath]);
             continue;
         }
         return false;
     }
     return count($fileStoreNewPhotos) == 0;
 }