Пример #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();
 }