Skip to content
This repository was archived by the owner on Jan 28, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
composer.phar
composer.lock
vendor/

.idea/
84 changes: 84 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- hhvm

mysql:
database: drupal
username: root
encoding: utf8

matrix:
fast_finish: true
allow_failures:
- php: hhvm

before_install:
- sudo apt-get update > /dev/null
- composer self-update

install:
# install php packages required for running a web server from drush on php 5.3
- sudo apt-get install -y --force-yes php5-cgi php5-mysql

# add composer's global bin directory to the path
# see: https://github.com/drush-ops/drush#install---composer
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- export SIMPLETEST_DB=mysql://root:@127.0.0.1/drupal


# Set the api token so we don't hit the github api limit
- composer config -g github-oauth.github.com $GITHUB_ACCESS_TOKEN

# Install drush
- composer global require drush/drush:dev-master -n
- phpenv rehash

# Create MySQL Database
- mysql -e 'create database drupal;'

# Add coveralls script
- composer require satooshi/php-coveralls:~0.6@stable

before_script:
# remove Xdebug as we don't need it and it causes
# PHP Fatal error: Maximum function nesting level of '256' reached
- phpenv config-rm xdebug.ini

# navigate out of module directory to prevent blown stack by recursive module lookup
- cd ../..

# download Drupal 8 core.
- wget -q -O - http://ftp.drupal.org/files/projects/drupal-8.0.x-dev.tar.gz | tar xz
- cd drupal-8.0.x-dev

# reference and enable s3filesystem in build site
- ln -s $(readlink -e $(cd -)) modules/s3filesystem

# Install the drupal composer manager
- wget -q -O - https://ftp.drupal.org/files/projects/composer_manager-8.x-1.x-dev.tar.gz | tar xz -C modules
- php modules/composer_manager/scripts/init.php
- composer drupal-update -n

# Install drupal default profile
- php -d sendmail_path=`which true` ~/.composer/vendor/bin/drush.php --yes --verbose site-install --db-url=$SIMPLETEST_DB
- drush pm-enable s3filesystem simpletest composer_manager --yes

# start a web server on port 8080, run in the background; wait for initialization
- drush runserver 127.0.0.1:8080 &
- until netstat -an 2>/dev/null | grep '8080.*LISTEN'; do true; done

# Setup coveralls log dir
- mkdir -p build/logs

# check the modules dir
- drush pm-list
- ls modules/

script: ./vendor/bin/phpunit -c core/ --coverage-clover build/logs/clover.xml --group s3filesystem

after_success:
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php vendor/bin/coveralls -v; fi;'
42 changes: 24 additions & 18 deletions config/schema/s3filesystem.schema.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# Schema for the configuration files of the S3 File System module.

s3filesystem.settings:
type: mapping
type: config_object
label: 'S3 File System Settings'
mapping:

s3:
type: mapping
label: 'S3 config'
mapping:

bucket:
type: string
label: 'S3 Bucket'

keyprefix:
type: string
label: 'S3 Prefix'

region:
type: string
label: 'S3 Region'
Expand All @@ -23,7 +26,7 @@ s3filesystem.settings:
type: boolean
label: 'If True, always serve files from S3 via HTTPS'

custom_s3_host:
custom_host:
type: mapping
label: 'S3 config'
mapping:
Expand All @@ -48,7 +51,6 @@ s3filesystem.settings:
type: boolean
label: 'Use custom CDN on http only'


ignore_cache:
type: boolean
label: 'S3 Prefix'
Expand All @@ -57,37 +59,41 @@ s3filesystem.settings:
type: string
label: 'Partial Refresh Prefix'

presigned_urls:
type: sequence
label: 'A list of timeouts and paths that should be delivered through a presigned url.'
sequence:
- type: string
presigned_urls:
type: sequence
label: 'A list of timeouts and paths that should be delivered through a presigned url.'
sequence:
- type: string

saveas:
type: sequence
label: 'A list of paths for which users will be forced to save the file, rather than displaying it in the browser.'
sequence:
- type: string
saveas:
type: sequence
label: 'A list of paths for which users will be forced to save the file, rather than displaying it in the browser.'
sequence:
- type: string

torrents:
type: sequence
label: 'A list of paths that should be delivered via BitTorrent.'
sequence:
- type: string
torrents:
type: sequence
label: 'A list of paths that should be delivered via BitTorrent.'
sequence:
- type: string

aws:
type: mapping
label: 'AWS Credentials'
mapping:

use_instance_profile:
type: boolean
label: 'If your Drupal site is running on an Amazon EC2 server, you may use the Instance Profile Credentials from that server rather than setting your AWS credentials directly.'

access_key:
type: string
label: 'Amazon Web Services Access Key'

secret_key:
type: string
label: 'Amazon Web Services Secret Key'

default_cache_config:
type: path
label: 'The default cache location for your EC2 Instance Profile Credentials.'
Expand Down
55 changes: 39 additions & 16 deletions s3filesystem.install
Original file line number Diff line number Diff line change
Expand Up @@ -103,32 +103,22 @@ function s3filesystem_schema() {
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'filesize' => array(
'description' => 'The size of the file in bytes.',
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'stat' => array(
'description' => 'Serialized stat array',
'type' => 'blob',
'size' => 'normal',
'not null' => TRUE,
'default' => 0,
),
'timestamp' => array(
'description' => 'UNIX timestamp for when the file was added.',
'expires' => array(
'description' => 'UNIX timestamp for when the cache expires.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'dir' => array(
'description' => 'Boolean indicating whether or not this object is a directory.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'timestamp' => array('timestamp'),
'uri' => array('uri'),
),
'primary key' => array('fid'),
Expand All @@ -150,3 +140,36 @@ function s3filesystem_install() {
// 'utf8_bin' collation fulfills our needs.
db_query("ALTER TABLE {file_s3filesystem} CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin");
}

/**
* Updates to use AWS Caching rather than custom caching tables
*/
function s3filesystem_update_8001(&$sandbox) {

$database = \Drupal::database();
$schema = $database->schema();

$database->query('TRUNCATE {file_s3filesystem}');

$spec = array(
'description' => 'Serialized stat array',
'type' => 'blob',
'size' => 'normal',
'not null' => TRUE,
);
$schema->addField('file_s3filesystem', 'stat', $spec);

$spec = array(
'description' => 'UNIX timestamp for when the cache expires.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
);
$schema->addField('file_s3filesystem', 'expires', $spec);

$schema->dropIndex('file_s3filesystem', 'timestamp');
$schema->dropField('file_s3filesystem', 'filesize');
$schema->dropField('file_s3filesystem', 'timestamp');
$schema->dropField('file_s3filesystem', 'dir');
}
16 changes: 11 additions & 5 deletions s3filesystem.services.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
parameters:
s3filesystem.stream_wrapper.class: Drupal\s3filesystem\StreamWrapper\S3StreamWrapper
s3filesystem.aws_client.factory.class: Drupal\s3filesystem\AWS\S3\ClientFactory
s3filesystem.aws_client.factory.class: Drupal\s3filesystem\Aws\S3\ClientFactory
s3filesystem.aws_client.class: Aws\S3\S3Client
s3filesystem.client.class: Drupal\s3filesystem\AWS\S3\DrupalAdaptor
s3filesystem.aws_client.s3.cache.class: Drupal\s3filesystem\Aws\StreamCache
s3filesystem.adaptor.class: Drupal\s3filesystem\Aws\S3\DrupalAdaptor

services:

Expand All @@ -11,15 +12,20 @@ services:
class: %s3filesystem.stream_wrapper.class%
arguments:
- @s3filesystem.aws_client

tags:
- { name: stream_wrapper, scheme: s3 }

s3filesystem.aws_client:
class: %s3filesystem.aws_client.class%
factory: [%s3filesystem.aws_client.factory.class%, create]

s3filesystem.client:
class: %s3filesystem.client.class%
s3filesystem.aws_client.s3.cache:
class: %s3filesystem.aws_client.s3.cache.class%
arguments:
- @database

s3filesystem.adaptor:
class: %s3filesystem.adaptor.class%
arguments:
- @s3filesystem.aws_client
- @config.factory
Loading