예제 #1
0
 /**
  * Returns the checksum of the specified file's content.
  *
  * @param string $key
  *
  * @return string A MD5 hash
  */
 public function checksum($key)
 {
     $this->assertHasFile($key);
     if ($this->adapter instanceof Adapter\ChecksumCalculator) {
         return $this->adapter->checksum($key);
     }
     return Util\Checksum::fromContent($this->read($key));
 }
예제 #2
0
 /**
  * {@inheritDoc}
  */
 public function checksum($key)
 {
     return Util\Checksum::fromContent($this->read($key));
 }
 /**
  * {@inheritdoc}
  */
 public function checksum($key)
 {
     $file = $this->find($key);
     return Util\Checksum::fromContent($file ? $file->getContentAsString() : '');
 }
예제 #4
0
 /**
  * {@inheritDoc}
  */
 public function write($key, $content, array $metadata = null)
 {
     $this->files[$key]['content'] = $content;
     $this->files[$key]['mtime'] = time();
     $this->files[$key]['checksum'] = Util\Checksum::fromContent($content);
     return Util\Size::fromContent($content);
 }
예제 #5
0
파일: Zip.php 프로젝트: novatex/Gaufrette
 /**
  * Returns the checksum of the file
  *
  * @param  string $key
  *
  * @return string
  */
 public function checksum($key)
 {
     $this->assertExists($key);
     return Util\Checksum::fromContent($this->read($key));
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function write($key, $content)
 {
     $values = array($this->getQuotedColumn('content') => $content, $this->getQuotedColumn('mtime') => time(), $this->getQuotedColumn('checksum') => Util\Checksum::fromContent($content));
     if ($this->exists($key)) {
         $this->connection->update($this->table, $values, array($this->getQuotedColumn('key') => $key));
     } else {
         $values[$this->getQuotedColumn('key')] = $key;
         $this->connection->insert($this->table, $values);
     }
     return Util\Size::fromContent($content);
 }
예제 #7
0
 public function testChecksumIsUpdatedOnWrite()
 {
     $adapter = new InMemory(array('foobar' => array('content' => 'Some content', 'checksum' => 'abcd')));
     $adapter->write('foobar', 'Changed content');
     $this->assertEquals(Checksum::fromContent('Changed content'), $adapter->checksum('foobar'));
 }