Ejemplo n.º 1
0
 /**
  * @param FileSync $fileSync
  */
 protected static function purgeFileSync(FileSync $fileSync)
 {
     KalturaLog::info("Purging file sync [" . $fileSync->getId() . "]");
     $fullPath = $fileSync->getFullPath();
     if ($fullPath && file_exists($fullPath)) {
         KalturaLog::debug("Purging file sync [" . $fileSync->getId() . "] path [{$fullPath}]");
         if (is_dir($fullPath)) {
             $command = "rm -fr {$fullPath}";
             KalturaLog::debug("Executing: {$command}");
             if (self::$dryRun) {
                 self::incrementSummary('dirs');
             } else {
                 $returnedValue = null;
                 passthru($command, $returnedValue);
                 if ($returnedValue === 0) {
                     self::incrementSummary('dirs');
                 } else {
                     KalturaLog::err("Failed purging file sync [" . $fileSync->getId() . "] directory path [{$fullPath}]");
                     return;
                 }
             }
         } else {
             $fileSize = filesize($fullPath);
             if (self::$dryRun || unlink($fullPath)) {
                 self::incrementSummary('bytes', $fileSize);
                 self::incrementSummary('files');
             } else {
                 KalturaLog::err("Failed purging file sync [" . $fileSync->getId() . "] file path [{$fullPath}]");
                 return;
             }
         }
     } else {
         KalturaLog::debug("File sync [" . $fileSync->getId() . "] path [{$fullPath}] does not exist");
     }
     $fileSync->setStatus(FileSync::FILE_SYNC_STATUS_PURGED);
     $fileSync->save();
 }
Ejemplo n.º 2
0
 /**
  * decrement the link_count field on a source file_sync record
  *
  * @param FileSync $fileSync
  * @return void
  */
 private static function decrementLinkCountForFileSync(FileSync $fileSync = null)
 {
     if (!$fileSync) {
         return;
     }
     $current_count = (int) $fileSync->getLinkCount() ? $fileSync->getLinkCount() - 1 : 0;
     $fileSync->setLinkCount($current_count);
     $fileSync->save();
 }
 /**
  * increment the link_count field on a source file_sync record
  *
  * @param FileSync $fileSync
  * @return void
  */
 private static function incrementLinkCountForFileSync(FileSync $fileSync)
 {
     $current_count = ((int) $fileSync->getLinkCount() ? $fileSync->getLinkCount() : 0) + 1;
     $fileSync->setLinkCount($current_count);
     $fileSync->save();
 }