Ejemplo n.º 1
0
 /**
  * @param Filesystem $filesystem
  * @param $path
  * @param $fileName
  * @param array|null $options
  */
 public function save(Filesystem $filesystem, $path, $fileName, array $options = null)
 {
     $origin = "{$path}/{$fileName}";
     $snapshotFileName = SnapshotManager::createNameForSnapshot();
     $target = "{$path}/{$snapshotFileName}";
     $freshFileName = SnapshotManager::FRESH_FILE;
     $freshFilePath = "{$path}/{$freshFileName}";
     $filesystem->rename($origin, $target);
     $filesystem->symlink($target, $freshFilePath);
 }
Ejemplo n.º 2
0
 /**
  * @param Filesystem $filesystem
  * @param $path
  * @param $fileName
  * @param array|null $options
  */
 public function save(Filesystem $filesystem, $path, $fileName, array $options = null)
 {
     // save the writing one to timestamp format,
     // change the Symlink to the new one,
     // and delete the old one
     $timeStampName = SnapshotManager::createNameForSnapshot();
     $freshFileName = SnapshotManager::FRESH_FILE;
     $originPath = "{$path}/{$fileName}";
     $targetPath = "{$path}/{$timeStampName}";
     $freshPath = "{$path}/{$freshFileName}";
     $filesystem->rename($originPath, $targetPath);
     // now the written file is on timestamp format
     $filesystem->symlink($targetPath, $freshPath);
     $filesystem->remove($options["siblings"]);
 }
Ejemplo n.º 3
0
 /**
  * @param QueryRequest $queryRequest
  * @throws SnapshotException
  */
 public function cleanSnapshots(QueryRequest $queryRequest)
 {
     //delete all snapshots
     try {
         $this->snapshotManager->init();
         $this->snapshotManager->setQueryRequest($queryRequest);
         $snapshots = $this->snapshotManager->getSnapshots();
         foreach ($snapshots as $snapshot) {
             /** @var SplFileInfo $snapshot */
             $this->snapshotManager->deleteSnapshot($snapshot);
         }
     } catch (SnapshotException $e) {
         throw $e;
     }
 }