Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function replace(BucketInterface $destination, $name)
 {
     if ($destination == $this) {
         return $this->buildAddress($name);
     }
     //Internal copying
     if ($this->getName() == $destination->getName()) {
         $this->logger()->info("Internal move '{$this->buildAddress($name)}' " . "to '{$destination->buildAddress($name)}' at '{$this->getName()}' server.");
         $benchmark = $this->benchmark($this->getName(), "replace::{$this->buildAddress($name)}");
         try {
             $this->server()->replace($this, $destination, $name);
         } finally {
             $this->benchmark($benchmark);
         }
     } else {
         $this->logger()->info("External move '{$this->getName()}'.'{$this->buildAddress($name)}'" . " to '{$destination->getName()}'.'{$destination->buildAddress($name)}'.");
         //Copying using temporary stream (buffer)
         $destination->put($name, $stream = $this->allocateStream($name));
         if ($stream->detach()) {
             //Dropping temporary stream
             $this->delete($name);
         }
     }
     return $destination->buildAddress($name);
 }