Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function updateStream($path, $resource, Config $config)
 {
     $result = $this->adapter->updateStream($path, $resource, $config);
     if ($result !== false) {
         $contents = false;
         $this->cache->updateObject($path, $result + compact('path', 'contents'), true);
     }
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 public function updateStream($path, $resource, Config $config)
 {
     if ($this->mainAdapter->has($path)) {
         return $this->mainAdapter->updateStream($path, $resource, $config);
     } else {
         // TODO: Review, is this necessary?
         return $this->mainAdapter->writeStream($path, $resource, $config);
     }
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function updateStream($path, $resource, Config $config)
 {
     if (!$this->source->updateStream($path, $resource, $config)) {
         return false;
     }
     if ($this->replica->has($path)) {
         return $this->replica->updateStream($path, $resource, $config);
     } else {
         return $this->replica->writeStream($path, $resource, $config);
     }
 }
Пример #4
0
 /**
  * Update a file on the source and replica
  *
  * @param   string $path
  * @param   resource $resource
  * @param   mixed  $config Config object or visibility setting
  *
  * @return  false|array  false on failure file meta data on success
  */
 public function updateStream($path, $resource, $config = null)
 {
     if (!$this->source->updateStream($path, $resource, $config)) {
         return false;
     }
     return $this->replica->updateStream($path, $resource, $config);
 }
 /**
  * {@inheritDoc}
  */
 public function updateStream($path, $resource, Config $config)
 {
     $success = $this->adapter->updateStream($path, $resource, $config);
     if ($success) {
         $this->cache->delete($this->getCacheKey($path));
     }
     return $success;
 }
 public function it_should_ignore_failed_streamed_updates()
 {
     $path = 'path.txt';
     $contents = tmpfile();
     $config = new Config();
     $this->adapter->updateStream($path, $contents, $config)->willReturn(false);
     $this->updateStream($path, $contents, $config)->shouldBe(false);
     fclose($contents);
 }
Пример #7
0
 /**
  * Update a file with the contents of a stream.
  *
  * @param string   $path
  * @param resource $resource
  * @param mixed    $config   Config object or visibility setting
  *
  * @throws InvalidArgumentException
  *
  * @return bool success boolean
  */
 public function updateStream($path, $resource, array $config = array())
 {
     if (!is_resource($resource)) {
         throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
     }
     $path = Util::normalizePath($path);
     $config = $this->prepareConfig($config);
     $this->assertPresent($path);
     Util::rewindStream($resource);
     return (bool) $this->adapter->updateStream($path, $resource, $config);
 }
Пример #8
0
 /**
  * {@inheritDoc}
  */
 public function updateStream($pathOrUuid, $resource, Config $config)
 {
     $path = $this->convertToPath($pathOrUuid);
     $this->guardNoInvalidUuid($pathOrUuid, $path);
     $this->guardInUploadPath($path);
     if ($this->adapter->updateStream($path, $resource, $config)) {
         \Dbafs::addResource($path);
         return true;
     }
     return false;
 }
Пример #9
0
 /**
  * Update a file with the contents of a stream
  *
  * @param   string    $path
  * @param   resource  $resource
  * @return  bool      success boolean
  * @throws  InvalidArgumentException
  */
 public function updateStream($path, $resource)
 {
     $path = Util::normalizePath($path);
     $this->assertPresent($path);
     if (!is_resource($resource)) {
         throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
     }
     if (!($object = $this->adapter->updateStream($path, $resource))) {
         return false;
     }
     $this->cache->updateObject($path, $object, true);
     $this->cache->ensureParentDirectories($path);
     return true;
 }
Пример #10
0
 /**
  * Update a file with the contents of a stream.
  *
  * @param string   $path
  * @param resource $resource
  * @param mixed    $config   Config object or visibility setting
  *
  * @throws InvalidArgumentException
  *
  * @return bool success boolean
  */
 public function updateStream($path, $resource, array $config = [])
 {
     if (!is_resource($resource)) {
         throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
     }
     $path = Util::normalizePath($path);
     $config = $this->prepareConfig($config);
     $this->assertPresent($path);
     Util::rewindStream($resource);
     if (!($object = $this->adapter->updateStream($path, $resource, $config))) {
         return false;
     }
     $this->cache->updateObject($path, $object + ['contents' => false], true);
     return true;
 }
Пример #11
0
 /**
  * {@inheritdoc}
  */
 public function put(string $path, $contents, array $config = []) : bool
 {
     $config['visibility'] = $this->parseVisibility($config['visibility'] ?? null) ?: [];
     $flyConfig = new FlyConfig($config);
     if (is_resource($contents)) {
         if ($this->has($path)) {
             return (bool) $this->driver->updateStream($path, $resource, $flyConfig);
         }
         return (bool) $this->driver->writeStream($path, $resource, $flyConfig);
     }
     if ($this->has($path)) {
         return (bool) $this->driver->update($path, $contents, $flyConfig);
     }
     return (bool) $this->driver->write($path, $contents, $flyConfig);
 }
Пример #12
0
 /**
  * Update a file with the contents of a stream
  *
  * @param   string    $path
  * @param   resource  $resource
  * @param   mixed     $config   Config object or visibility setting
  * @return  bool      success boolean
  * @throws  InvalidArgumentException
  */
 public function updateStream($path, $resource, $config = null)
 {
     if (!is_resource($resource)) {
         throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
     }
     $path = Util::normalizePath($path);
     $config = Util::ensureConfig($config);
     $config->setFallback($this->getConfig());
     $this->assertPresent($path);
     Util::rewindStream($resource);
     if (!($object = $this->adapter->updateStream($path, $resource, $config))) {
         return false;
     }
     $this->cache->updateObject($path, $object, true);
     return true;
 }
Пример #13
0
 /**
  * {@inheritdoc}
  */
 public function updateStream($path, $resource, Config $config)
 {
     return $this->adapter->updateStream($this->getPath($path), $resource, $config);
 }