Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/nbproject/
29 changes: 13 additions & 16 deletions FSs3Repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function __construct( $info ) {

// Optional settings
$this->AWS_S3_PUBLIC = isset( $info['AWS_S3_PUBLIC'] ) ? $info['AWS_S3_PUBLIC'] : false;
$s3->useSSL = $this->AWS_S3_SSL = isset( $info['AWS_S3_SSL'] ) ? $info['AWS_S3_SSL'] : true;
$s3::$useSSL = $this->AWS_S3_SSL = isset( $info['AWS_S3_SSL'] ) ? $info['AWS_S3_SSL'] : true;
$this->url = isset( $info['url'] ) ? $info['url'] :
($this->AWS_S3_SSL ? "https://" : "http://") . "s3.amazonaws.com/" .
$this->AWS_S3_BUCKET . "/" . $this->directory;
Expand Down Expand Up @@ -88,7 +88,7 @@ function isHashed() {
/**
* Get the S3 directory corresponding to one of the three basic zones
*/
function getZonePath( $zone ) {
function getZonePath($zone, $ext = NULL) {
switch ( $zone ) {
case 'public':
return $this->directory;
Expand All @@ -106,7 +106,7 @@ function getZonePath( $zone ) {
/** Returns zone part of repo URL, plus base URL, to be appended to S3 base URL
* @see FileRepo::getZoneUrl()
*/
function getZoneUrl( $zone ) {
function getZoneUrl($zone, $ext = NULL) {
switch ( $zone ) {
case 'public':
$retval = $this->url;
Expand Down Expand Up @@ -175,7 +175,7 @@ function resolveVirtualUrl( $url ) {
* self::OVERWRITE_SAME Overwrite the file if the destination exists and has the
* same contents as the source (not implemented in S3)
*/
function storeBatch( $triplets, $flags = 0 ) {
function storeBatch(array $triplets, $flags = 0) {
wfDebug(__METHOD__." triplets: ".print_r($triplets,true)."flags: ".print_r($flags)."\n");
global $s3;
$status = $this->newGood();
Expand All @@ -192,7 +192,7 @@ function storeBatch( $triplets, $flags = 0 ) {
$dstPath = "$root/$dstRel";

if ( self::isVirtualUrl( $srcPath ) ) {
$srcPath = $triplets[$i][0] = $this->resolveVirtualUrl( $srcPath );
$srcPath = $ntuples[$i][0] = $this->resolveVirtualUrl( $srcPath );
}
$s3path = $srcPath;
$info = $s3->getObjectInfo($this->AWS_S3_BUCKET, $s3path);
Expand Down Expand Up @@ -334,12 +334,9 @@ function append( $srcPath, $toAppendPath, $flags = 0 ) {
* Checks existence of specified array of files.
*
* @param $files Array: URLs of files to check
* @param $flags Integer: bitwise combination of the following flags:
* self::FILES_ONLY Mark file as existing only if it is a file (not directory)
* Will mark all items found on S3 as true, no directory concept exists on the S3
* @return Either array of files and existence flags, or false
*/
function fileExistsBatch( $files, $flags = 0 ) {
function fileExistsBatch(array $files) {
global $s3;
$result = array();
foreach ( $files as $key => $file ) {
Expand Down Expand Up @@ -403,21 +400,21 @@ function freeTemp( $virtualUrl ) {

/**
* Publish a batch of files
* @param $triplets Array: (source,dest,archive) triplets as per publish()
* @param $ntuples Array: (source,dest,archive) triplets as per publish()
* source can be on local machine or on S3, dest must be on S3
* @param $flags Integer: bitfield, may be FileRepo::DELETE_SOURCE to indicate
* that the source files should be deleted if possible
*/
function publishBatch( $triplets, $flags = 0 ) {
function publishBatch(array $ntuples, $flags = 0 ) {
// Perform initial checks
wfDebug(__METHOD__.": ".print_r($triplets,true));
wfDebug(__METHOD__.": ".print_r($ntuples,true));
global $s3;
$status = $this->newGood( array() );
foreach ( $triplets as $i => $triplet ) {
foreach ( $ntuples as $i => $triplet ) {
list( $srcPath, $dstRel, $archiveRel ) = $triplet;

if ( substr( $srcPath, 0, 9 ) == 'mwrepo://' ) {
$triplets[$i][0] = $srcPath = $this->resolveVirtualUrl( $srcPath );
$ntuples[$i][0] = $srcPath = $this->resolveVirtualUrl( $srcPath );
}
if ( !$this->validateFilename( $dstRel ) ) {
throw new MWException( 'Validation error in $dstRel' );
Expand All @@ -443,7 +440,7 @@ function publishBatch( $triplets, $flags = 0 ) {
return $status;
}

foreach ( $triplets as $i => $triplet ) {
foreach ( $ntuples as $i => $triplet ) {
list( $srcPath, $dstRel, $archiveRel ) = $triplet;
$dstPath = "{$this->directory}/$dstRel";
$archivePath = "{$this->directory}/$archiveRel";
Expand Down Expand Up @@ -545,7 +542,7 @@ function publishBatch( $triplets, $flags = 0 ) {
* to the deleted zone root in the second element.
* @return FileRepoStatus
*/
function deleteBatch( $sourceDestPairs ) {
function deleteBatch(array $sourceDestPairs) {
wfDebug(__METHOD__.": ".print_r($sourceDestPairs,true)."\n");
global $s3;
$status = $this->newGood();
Expand Down
Loading