예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function getBackupsToRemove(BackupCollection $existingBackups, Backup $newBackup)
 {
     $size = $existingBackups->getTotalFileSize() + $newBackup->getSize();
     if ($size < $this->maxSize) {
         return new BackupCollection();
     }
     $backupsToRemove = array();
     /** @var Backup[] $existingBackups */
     foreach ($existingBackups as $backup) {
         $backupsToRemove[] = $backup;
         $size -= $backup->getSize();
         if ($size < $this->maxSize) {
             break;
         }
     }
     return new BackupCollection($backupsToRemove);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function all()
 {
     $backups = array();
     /** @var SplFileInfo[] $files */
     $files = Finder::create()->in($this->directory)->files()->depth(0)->sortByModifiedTime();
     foreach ($files as $file) {
         $backups[] = Backup::fromFile($file->getPathname());
     }
     return $backups;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function push($filename, LoggerInterface $logger)
 {
     $this->doRotate(Backup::fromFile($filename), $logger);
     return $this->destination->push($filename, $logger);
 }