[Pkg-owncloud-commits] [owncloud] 66/67: Update php-opencloud related patch
David Prévot
taffit at moszumanska.debian.org
Fri Jun 27 23:58:20 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 0f429a6f118259ad1fb031b4383b561a9ca1a82b
Author: David Prévot <taffit at debian.org>
Date: Thu Jun 26 18:08:33 2014 -0400
Update php-opencloud related patch
Git-Dch: Ignore
---
...10-Disable-Flash-and-Silverlight-plugins.patch} | 0
...es_external-swift-to-php-opencloud-v1.9.2.patch | 433 +++++++++++++++++++++
.../path/0010-Adapt-php-opencloud-path.patch | 26 --
debian/patches/series | 4 +-
4 files changed, 435 insertions(+), 28 deletions(-)
diff --git a/debian/patches/0011-Disable-Flash-and-Silverlight-plugins.patch b/debian/patches/0010-Disable-Flash-and-Silverlight-plugins.patch
similarity index 100%
rename from debian/patches/0011-Disable-Flash-and-Silverlight-plugins.patch
rename to debian/patches/0010-Disable-Flash-and-Silverlight-plugins.patch
diff --git a/debian/patches/0011-update-files_external-swift-to-php-opencloud-v1.9.2.patch b/debian/patches/0011-update-files_external-swift-to-php-opencloud-v1.9.2.patch
new file mode 100644
index 0000000..7a3b123
--- /dev/null
+++ b/debian/patches/0011-update-files_external-swift-to-php-opencloud-v1.9.2.patch
@@ -0,0 +1,433 @@
+From: =?utf-8?q?J=C3=B6rn_Friedrich_Dreyer?= <jfd at butonic.de>
+Date: Wed, 25 Jun 2014 14:56:16 +0200
+Subject: update files_external swift to php-opencloud v1.9.2
+
+Origin: upstream, https://github.com/owncloud/core/commit/42e9d49d72cd424335bed79b5b8347caa7a34f45
+---
+ apps/files_external/lib/swift.php | 218 ++++++++++++++++++------------------
+ apps/files_external/tests/swift.php | 11 +-
+ 2 files changed, 113 insertions(+), 116 deletions(-)
+
+diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
+index 0336486..47ab329 100644
+--- a/apps/files_external/lib/swift.php
++++ b/apps/files_external/lib/swift.php
+@@ -22,21 +22,21 @@
+
+ namespace OC\Files\Storage;
+
+-set_include_path(get_include_path() . PATH_SEPARATOR .
+- \OC_App::getAppPath('files_external') . '/3rdparty/php-opencloud/lib');
+-require_once 'openstack.php';
+-
+-use \OpenCloud;
+-use \OpenCloud\Common\Exceptions;
++use Guzzle\Http\Exception\ClientErrorResponseException;
++use OpenCloud;
++use OpenCloud\Common\Exceptions;
++use OpenCloud\OpenStack;
++use OpenCloud\ObjectStore\Resource\DataObject;
++use OpenCloud\ObjectStore\Exception;
+
+ class Swift extends \OC\Files\Storage\Common {
+
+ /**
+- * @var \OpenCloud\ObjectStore
++ * @var \OpenCloud\ObjectStore\Service
+ */
+ private $connection;
+ /**
+- * @var \OpenCloud\ObjectStore\Container
++ * @var \OpenCloud\ObjectStore\Resource\Container
+ */
+ private $container;
+ /**
+@@ -62,6 +62,8 @@ class Swift extends \OC\Files\Storage\Common {
+ $path = '.';
+ }
+
++ $path = str_replace('#', '%23', $path);
++
+ return $path;
+ }
+
+@@ -82,12 +84,9 @@ class Swift extends \OC\Files\Storage\Common {
+ */
+ private function doesObjectExist($path) {
+ try {
+- $object = $this->container->DataObject($path);
++ $this->container->getPartialObject($path);
+ return true;
+- } catch (Exceptions\ObjFetchError $e) {
+- \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
+- return false;
+- } catch (Exceptions\HttpError $e) {
++ } catch (ClientErrorResponseException $e) {
+ \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
+ return false;
+ }
+@@ -113,7 +112,6 @@ class Swift extends \OC\Files\Storage\Common {
+
+ $settings = array(
+ 'username' => $params['user'],
+-
+ );
+
+ if (isset($params['password'])) {
+@@ -126,19 +124,18 @@ class Swift extends \OC\Files\Storage\Common {
+ $settings['tenantName'] = $params['tenant'];
+ }
+
+- $this->anchor = new \OpenCloud\OpenStack($params['url'], $settings);
+-
+ if (isset($params['timeout'])) {
+- $this->anchor->setHttpTimeout($params['timeout']);
++ $settings['timeout'] = $params['timeout'];
+ }
+
+- $this->connection = $this->anchor->ObjectStore($params['service_name'], $params['region'], 'publicURL');
++ $this->anchor = new OpenStack($params['url'], $settings);
++
++ $this->connection = $this->anchor->objectStoreService($params['service_name'], $params['region']);
+
+ try {
+- $this->container = $this->connection->Container($this->bucket);
+- } catch (Exceptions\ContainerNotFoundError $e) {
+- $this->container = $this->connection->Container();
+- $this->container->Create(array('name' => $this->bucket));
++ $this->container = $this->connection->getContainer($this->bucket);
++ } catch (ClientErrorResponseException $e) {
++ $this->container = $this->connection->createContainer($this->bucket);
+ }
+
+ if (!$this->file_exists('.')) {
+@@ -158,11 +155,10 @@ class Swift extends \OC\Files\Storage\Common {
+ }
+
+ try {
+- $object = $this->container->DataObject();
+- $object->Create(array(
+- 'name' => $path,
+- 'content_type' => 'httpd/unix-directory'
+- ));
++ $customHeaders = array('content-type' => 'httpd/unix-directory');
++ $metadataHeaders = DataObject::stockHeaders(array());
++ $allHeaders = $customHeaders + $metadataHeaders;
++ $this->container->uploadObject($path, '', $allHeaders);
+ } catch (Exceptions\CreateUpdateError $e) {
+ \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
+ return false;
+@@ -202,8 +198,7 @@ class Swift extends \OC\Files\Storage\Common {
+ }
+
+ try {
+- $object = $this->container->DataObject($path . '/');
+- $object->Delete();
++ $this->container->dataObject()->setName($path . '/')->delete();
+ } catch (Exceptions\DeleteError $e) {
+ \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
+ return false;
+@@ -221,15 +216,19 @@ class Swift extends \OC\Files\Storage\Common {
+ $path .= '/';
+ }
+
++ $path = str_replace('%23', '#', $path); // the prefix is sent as a query param, so revert the encoding of #
++
+ try {
+ $files = array();
+- $objects = $this->container->ObjectList(array(
++ /** @var OpenCloud\Common\Collection $objects */
++ $objects = $this->container->objectList(array(
+ 'prefix' => $path,
+ 'delimiter' => '/'
+ ));
+
+- while ($object = $objects->Next()) {
+- $file = basename($object->Name());
++ /** @var OpenCloud\ObjectStore\Resource\DataObject $object */
++ foreach ($objects as $object) {
++ $file = basename($object->getName());
+ if ($file !== basename($path)) {
+ $files[] = $file;
+ }
+@@ -252,15 +251,22 @@ class Swift extends \OC\Files\Storage\Common {
+ }
+
+ try {
+- $object = $this->container->DataObject($path);
+- } catch (Exceptions\ObjFetchError $e) {
++ $object = $this->container->getPartialObject($path);
++ } catch (ClientErrorResponseException $e) {
+ \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
+ return false;
+ }
+
+- $mtime = $object->extra_headers['X-Timestamp'];
+- if (isset($object->extra_headers['X-Object-Meta-Timestamp'])) {
+- $mtime = $object->extra_headers['X-Object-Meta-Timestamp'];
++ $dateTime = \DateTime::createFromFormat(\DateTime::RFC1123, $object->getLastModified());
++ if ($dateTime !== false) {
++ $mtime = $dateTime->getTimestamp();
++ } else {
++ $mtime = null;
++ }
++ $objectMetadata = $object->getMetadata();
++ $metaTimestamp = $objectMetadata->getProperty('timestamp');
++ if (isset($metaTimestamp)) {
++ $mtime = $metaTimestamp;
+ }
+
+ if (!empty($mtime)) {
+@@ -268,7 +274,7 @@ class Swift extends \OC\Files\Storage\Common {
+ }
+
+ $stat = array();
+- $stat['size'] = $object->content_length;
++ $stat['size'] = (int) $object->getContentLength();
+ $stat['mtime'] = $mtime;
+ $stat['atime'] = time();
+ return $stat;
+@@ -293,13 +299,13 @@ class Swift extends \OC\Files\Storage\Common {
+ public function unlink($path) {
+ $path = $this->normalizePath($path);
+
++ if ($this->is_dir($path)) {
++ return $this->rmdir($path);
++ }
++
+ try {
+- $object = $this->container->DataObject($path);
+- $object->Delete();
+- } catch (Exceptions\DeleteError $e) {
+- \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
+- return false;
+- } catch (Exceptions\ObjFetchError $e) {
++ $this->container->dataObject()->setName($path)->delete();
++ } catch (ClientErrorResponseException $e) {
+ \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
+ return false;
+ }
+@@ -316,13 +322,19 @@ class Swift extends \OC\Files\Storage\Common {
+ $tmpFile = \OC_Helper::tmpFile();
+ self::$tmpFiles[$tmpFile] = $path;
+ try {
+- $object = $this->container->DataObject($path);
+- } catch (Exceptions\ObjFetchError $e) {
++ $object = $this->container->getObject($path);
++ } catch (ClientErrorResponseException $e) {
++ \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
++ return false;
++ } catch (Exception\ObjectNotFoundException $e) {
+ \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
+ return false;
+ }
+ try {
+- $object->SaveToFilename($tmpFile);
++ $objectContent = $object->getContent();
++ $objectContent->rewind();
++ $stream = $objectContent->getStream();
++ file_put_contents($tmpFile, $stream);
+ } catch (Exceptions\IOError $e) {
+ \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
+ return false;
+@@ -363,43 +375,32 @@ class Swift extends \OC\Files\Storage\Common {
+ if ($this->is_dir($path)) {
+ return 'httpd/unix-directory';
+ } else if ($this->file_exists($path)) {
+- $object = $this->container->DataObject($path);
+- return $object->extra_headers["Content-Type"];
++ $object = $this->container->getPartialObject($path);
++ return $object->getContentType();
+ }
+ return false;
+ }
+
+ public function touch($path, $mtime = null) {
+ $path = $this->normalizePath($path);
++ if (is_null($mtime)) {
++ $mtime = time();
++ }
++ $metadata = array('timestamp' => $mtime);
+ if ($this->file_exists($path)) {
+ if ($this->is_dir($path) && $path != '.') {
+ $path .= '/';
+ }
+
+- $object = $this->container->DataObject($path);
+- if( is_null($mtime)) {
+- $mtime = time();
+- }
+- $settings = array(
+- 'name' => $path,
+- 'extra_headers' => array(
+- 'X-Object-Meta-Timestamp' => $mtime
+- )
+- );
+- return $object->UpdateMetadata($settings);
++ $object = $this->container->getPartialObject($path);
++ $object->saveMetadata($metadata);
++ return true;
+ } else {
+- $object = $this->container->DataObject();
+- if (is_null($mtime)) {
+- $mtime = time();
+- }
+- $settings = array(
+- 'name' => $path,
+- 'content_type' => 'text/plain',
+- 'extra_headers' => array(
+- 'X-Object-Meta-Timestamp' => $mtime
+- )
+- );
+- return $object->Create($settings);
++ $customHeaders = array('content-type' => 'text/plain');
++ $metadataHeaders = DataObject::stockHeaders($metadata);
++ $allHeaders = $customHeaders + $metadataHeaders;
++ $this->container->uploadObject($path, '', $allHeaders);
++ return true;
+ }
+ }
+
+@@ -407,31 +408,29 @@ class Swift extends \OC\Files\Storage\Common {
+ $path1 = $this->normalizePath($path1);
+ $path2 = $this->normalizePath($path2);
+
+- if ($this->is_file($path1)) {
++ $fileType = $this->filetype($path1);
++ if ($fileType === 'file') {
++
++ // make way
++ $this->unlink($path2);
++
+ try {
+- $source = $this->container->DataObject($path1);
+- $target = $this->container->DataObject();
+- $target->Create(array(
+- 'name' => $path2,
+- ));
+- $source->Copy($target);
+- } catch (Exceptions\ObjectCopyError $e) {
++ $source = $this->container->getPartialObject($path1);
++ $source->copy($this->bucket.'/'.$path2);
++ } catch (ClientErrorResponseException $e) {
+ \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
+ return false;
+ }
+- } else {
+- if ($this->file_exists($path2)) {
+- return false;
+- }
++
++ } else if ($fileType === 'dir') {
++
++ // make way
++ $this->unlink($path2);
+
+ try {
+- $source = $this->container->DataObject($path1 . '/');
+- $target = $this->container->DataObject();
+- $target->Create(array(
+- 'name' => $path2 . '/',
+- ));
+- $source->Copy($target);
+- } catch (Exceptions\ObjectCopyError $e) {
++ $source = $this->container->getPartialObject($path1 . '/');
++ $source->copy($this->bucket.'/'.$path2 . '/');
++ } catch (ClientErrorResponseException $e) {
+ \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
+ return false;
+ }
+@@ -446,6 +445,10 @@ class Swift extends \OC\Files\Storage\Common {
+ $target = $path2 . '/' . $file;
+ $this->copy($source, $target);
+ }
++
++ } else {
++ //file does not exist
++ return false;
+ }
+
+ return true;
+@@ -455,31 +458,28 @@ class Swift extends \OC\Files\Storage\Common {
+ $path1 = $this->normalizePath($path1);
+ $path2 = $this->normalizePath($path2);
+
+- if ($this->is_file($path1)) {
++ $fileType = $this->filetype($path1);
++
++ if ($fileType === 'dir' || $fileType === 'file') {
++
++ // make way
++ $this->unlink($path2);
++
++ // copy
+ if ($this->copy($path1, $path2) === false) {
+ return false;
+ }
+
++ // cleanup
+ if ($this->unlink($path1) === false) {
+ $this->unlink($path2);
+ return false;
+ }
+- } else {
+- if ($this->file_exists($path2)) {
+- return false;
+- }
+-
+- if ($this->copy($path1, $path2) === false) {
+- return false;
+- }
+
+- if ($this->rmdir($path1) === false) {
+- $this->rmdir($path2);
+- return false;
+- }
++ return true;
+ }
+
+- return true;
++ return false;
+ }
+
+ public function getId() {
+@@ -494,12 +494,8 @@ class Swift extends \OC\Files\Storage\Common {
+ if (!isset(self::$tmpFiles[$tmpFile])) {
+ return false;
+ }
+-
+- $object = $this->container->DataObject();
+- $object->Create(array(
+- 'name' => self::$tmpFiles[$tmpFile],
+- 'content_type' => \OC_Helper::getMimeType($tmpFile)
+- ), $tmpFile);
++ $fileData = fopen($tmpFile, 'r');
++ $this->container->uploadObject(self::$tmpFiles[$tmpFile], $fileData);
+ unlink($tmpFile);
+ }
+
+diff --git a/apps/files_external/tests/swift.php b/apps/files_external/tests/swift.php
+index bdfdbde..3918497 100644
+--- a/apps/files_external/tests/swift.php
++++ b/apps/files_external/tests/swift.php
+@@ -38,14 +38,15 @@ class Swift extends Storage {
+ public function tearDown() {
+ if ($this->instance) {
+ $connection = $this->instance->getConnection();
+- $container = $connection->Container($this->config['swift']['bucket']);
++ $container = $connection->getContainer($this->config['swift']['bucket']);
+
+- $objects = $container->ObjectList();
+- while($object = $objects->Next()) {
+- $object->Delete();
++ $objects = $container->objectList();
++ while($object = $objects->next()) {
++ $object->setName(str_replace('#','%23',$object->getName()));
++ $object->delete();
+ }
+
+- $container->Delete();
++ $container->delete();
+ }
+ }
+ }
diff --git a/debian/patches/path/0010-Adapt-php-opencloud-path.patch b/debian/patches/path/0010-Adapt-php-opencloud-path.patch
deleted file mode 100644
index f209059..0000000
--- a/debian/patches/path/0010-Adapt-php-opencloud-path.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit at debian.org>
-Date: Tue, 5 Nov 2013 20:39:37 -0400
-Subject: Adapt php-opencloud path
-
-The Debian package depends on the needed classes instead of embedding
-them, i.e. php-opencloud.
-
-Forwarded: not-needed
-Last-Update: 2014-04-22
----
- apps/files_external/lib/swift.php | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
-index 0336486..c539173 100644
---- a/apps/files_external/lib/swift.php
-+++ b/apps/files_external/lib/swift.php
-@@ -23,7 +23,7 @@
- namespace OC\Files\Storage;
-
- set_include_path(get_include_path() . PATH_SEPARATOR .
-- \OC_App::getAppPath('files_external') . '/3rdparty/php-opencloud/lib');
-+ '/usr/share/php/php-opencloud');
- require_once 'openstack.php';
-
- use \OpenCloud;
diff --git a/debian/patches/series b/debian/patches/series
index 82043a2..c7fa28a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -7,5 +7,5 @@ path/0006-Adapt-Crypt_Blowfish-path.patch
path/0007-Adapt-aws-sdk-path.patch
path/0008-Adapt-google-api-php-client-path.patch
path/0009-Adapt-Dropbox-path.patch
-path/0010-Adapt-php-opencloud-path.patch
-0011-Disable-Flash-and-Silverlight-plugins.patch
+0010-Disable-Flash-and-Silverlight-plugins.patch
+0011-update-files_external-swift-to-php-opencloud-v1.9.2.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list