diff options
Diffstat (limited to 'apps/files_external/lib/amazons3.php')
-rw-r--r-- | apps/files_external/lib/amazons3.php | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index 41ec3c70b45..235ade06db6 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -45,7 +45,7 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common { if ($response) { $this->objects[$path] = $response; return $response; - // This object could be a folder, a '/' must be at the end of the path + // This object could be a folder, a '/' must be at the end of the path } else if (substr($path, -1) != '/') { $response = $this->s3->get_object_metadata($this->bucket, $path.'/'); if ($response) { @@ -108,11 +108,14 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common { $stat['atime'] = time(); $stat['mtime'] = $stat['atime']; $stat['ctime'] = $stat['atime']; - } else if ($object = $this->getObject($path)) { - $stat['size'] = $object['Size']; - $stat['atime'] = time(); - $stat['mtime'] = strtotime($object['LastModified']); - $stat['ctime'] = $stat['mtime']; + } else { + $object = $this->getObject($path); + if ($object) { + $stat['size'] = $object['Size']; + $stat['atime'] = time(); + $stat['mtime'] = strtotime($object['LastModified']); + $stat['ctime'] = $stat['mtime']; + } } if (isset($stat)) { return $stat; @@ -123,12 +126,15 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common { public function filetype($path) { if ($path == '' || $path == '/') { return 'dir'; - } else if ($object = $this->getObject($path)) { - // Amazon S3 doesn't have typical folders, this is an alternative method to detect a folder - if (substr($object['Key'], -1) == '/' && $object['Size'] == 0) { - return 'dir'; - } else { - return 'file'; + } else { + $object = $this->getObject($path); + if ($object) { + // Amazon S3 doesn't have typical folders, this is an alternative method to detect a folder + if (substr($object['Key'], -1) == '/' && $object['Size'] == 0) { + return 'dir'; + } else { + return 'file'; + } } } return false; @@ -199,7 +205,9 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common { public function writeBack($tmpFile) { if (isset(self::$tempFiles[$tmpFile])) { $handle = fopen($tmpFile, 'r'); - $response = $this->s3->create_object($this->bucket, self::$tempFiles[$tmpFile], array('fileUpload' => $handle)); + $response = $this->s3->create_object($this->bucket, + self::$tempFiles[$tmpFile], + array('fileUpload' => $handle)); if ($response->isOK()) { unlink($tmpFile); } @@ -209,8 +217,11 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common { public function getMimeType($path) { if ($this->filetype($path) == 'dir') { return 'httpd/unix-directory'; - } else if ($object = $this->getObject($path)) { - return $object['ContentType']; + } else { + $object = $this->getObject($path); + if ($object) { + return $object['ContentType']; + } } return false; } |