You are here

protected function S3fsStreamWrapper::_write_cache in S3 File System 7

Same name and namespace in other branches
  1. 7.3 S3fsStreamWrapper.inc \S3fsStreamWrapper::_write_cache()
  2. 7.2 S3fsStreamWrapper.inc \S3fsStreamWrapper::_write_cache()

Write an object's (and its ancestor folders') metadata to the cache.

Parameters

array $metadata: An associative array of file metadata, in this format: 'uri' => The full URI of the file, including 's3://'. 'filesize' => The size of the file, in bytes. 'timestamp' => The file's create/update timestamp. 'dir' => A boolean indicating whether the object is a directory. 'mode' => The octal mode of the file. 'uid' => The uid of the owner of the S3 object.

Throws

Exceptions which occur in the database call will percolate.

3 calls to S3fsStreamWrapper::_write_cache()
S3fsStreamWrapper::mkdir in ./S3fsStreamWrapper.inc
Support for mkdir().
S3fsStreamWrapper::rename in ./S3fsStreamWrapper.inc
Support for rename().
S3fsStreamWrapper::stream_flush in ./S3fsStreamWrapper.inc
Support for fflush(). Flush current cached stream data to a file in S3.

File

./S3fsStreamWrapper.inc, line 1221
Drupal stream wrapper implementation for S3 File System.

Class

S3fsStreamWrapper
The stream wrapper class.

Code

protected function _write_cache($metadata) {
  $this
    ->_debug("_write_cache({$metadata['uri']}) called.", TRUE);
  db_merge('s3fs_file')
    ->key(array(
    'uri' => $metadata['uri'],
  ))
    ->fields($metadata)
    ->execute();
  $dirname = $this
    ->dirname($metadata['uri']);
  if ($dirname != 's3://') {
    $this
      ->mkdir($dirname, NULL, STREAM_MKDIR_RECURSIVE);
  }
}