public function copy($from, $to)
{
+ if (!file_exists($from)) {
+ throw new \Exception(sprintf('File %s doen\'t exist', $from));
+ }
$realto = $this->path($to);
if (!$realto) {
return $this;
public function copyDirectory($from, $to)
{
+ if (!file_exists($from)) {
+ throw new \Exception(sprintf('Directory %s doen\'t exist', $from));
+ }
$this->_directories[$this->path($to)] = $from;
return $this;
}
file_put_contents($to, $data);
}
+ //dd($this->_copy);
+
foreach ($this->_copy as $to => $from) {
if (!file_exists($from)) {
continue;
if ($delete) {
$existing[$to] = true;
}
- if (!file_exists($to) || filesize($from) != filesize($to) || filemtime($from) > filemtime($to)) {
+
+ if (!file_exists($from)) {
+ throw new \Exception(sprintf('Failed to copy %s to %s. Source doesn\'t exist', $from, $to));
+ }
+
+ if (!file_exists($to) || filesize($from) !== filesize($to) || filemtime($from) > filemtime($to)) {
try {
copy($from, $to);
} catch (\Exception $e) {
$this->cleanTemp();
}
+ /**
+ * @throws \Exception
+ */
protected function _addDirectory($from, $to)
{
- if (!file_exists($from)) {
- return;
- }
-
$from = realpath($from);
$files = Files::getRecursiveDirectoryIterator($from);