public static function remove($file, $silenceErrors = false)
{
if (!file_exists($file)) {
return;
}
$result = @unlink($file);
// Testing if the file still exist avoids race conditions
if (!$result && file_exists($file)) {
if ($silenceErrors) {
Log::warning('Failed to delete file ' . $file);
} else {
throw new \RuntimeException('Unable to delete file ' . $file);
}
}
}
public function delete() { if ($this->exists()) { try { Filesystem::remove($this->getAbsoluteLocation()); } catch (Exception $e) { throw new Exception("Unable to delete merged file : " . $this->getAbsoluteLocation() . ". Please delete the file and refresh"); } // try to remove compressed version of the merged file. Filesystem::remove($this->getAbsoluteLocation() . ".deflate", true); Filesystem::remove($this->getAbsoluteLocation() . ".gz", true); } }