diff options
Diffstat (limited to 'apps/files_external')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/AmazonS3.php | 16 | ||||
-rw-r--r-- | apps/files_external/lib/Lib/Storage/SFTP.php | 3 | ||||
-rw-r--r-- | apps/files_external/tests/PersonalMountTest.php | 7 |
3 files changed, 23 insertions, 3 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 2c01a803840..cfd78689fa4 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -732,8 +732,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { if ($this->versioningEnabled === null) { $cached = $this->memCache->get('versioning-enabled::' . $this->getBucket()); if ($cached === null) { - $result = $this->getConnection()->getBucketVersioning(['Bucket' => $this->getBucket()]); - $this->versioningEnabled = $result->get('Status') === 'Enabled'; + $this->versioningEnabled = $this->getVersioningStatusFromBucket(); $this->memCache->set('versioning-enabled::' . $this->getBucket(), $this->versioningEnabled, 60); } else { $this->versioningEnabled = $cached; @@ -742,6 +741,19 @@ class AmazonS3 extends \OC\Files\Storage\Common { return $this->versioningEnabled; } + protected function getVersioningStatusFromBucket(): bool { + try { + $result = $this->getConnection()->getBucketVersioning(['Bucket' => $this->getBucket()]); + return $result->get('Status') === 'Enabled'; + } catch (S3Exception $s3Exception) { + // This is needed for compatibility with Storj gateway which does not support versioning yet + if ($s3Exception->getAwsErrorCode() === 'NotImplemented') { + return false; + } + throw $s3Exception; + } + } + public function hasUpdated($path, $time) { // for files we can get the proper mtime if ($path !== '' && $object = $this->headObject($path)) { diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php index ae049007cdc..e46f60d0be4 100644 --- a/apps/files_external/lib/Lib/Storage/SFTP.php +++ b/apps/files_external/lib/Lib/Storage/SFTP.php @@ -327,6 +327,9 @@ class SFTP extends \OC\Files\Storage\Common { public function filetype($path) { try { $stat = $this->getConnection()->stat($this->absPath($path)); + if (!is_array($stat) || !array_key_exists('type', $stat)) { + return false; + } if ((int) $stat['type'] === NET_SFTP_TYPE_REGULAR) { return 'file'; } diff --git a/apps/files_external/tests/PersonalMountTest.php b/apps/files_external/tests/PersonalMountTest.php index b8a57657f9d..024695b0188 100644 --- a/apps/files_external/tests/PersonalMountTest.php +++ b/apps/files_external/tests/PersonalMountTest.php @@ -25,8 +25,13 @@ namespace OCA\Files_External\Tests; use OC\Files\Mount\Manager; +use OC\Files\SetupManagerFactory; use OCA\Files_External\Lib\PersonalMount; use OCA\Files_External\Lib\StorageConfig; +use OCP\Diagnostics\IEventLogger; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\Files\Config\IMountProviderCollection; +use OCP\IUserManager; use Test\TestCase; class PersonalMountTest extends TestCase { @@ -47,7 +52,7 @@ class PersonalMountTest extends TestCase { $mount = new PersonalMount($storageService, $storageConfig, 10, $storage, '/foo'); - $mountManager = new Manager(); + $mountManager = new Manager($this->createMock(SetupManagerFactory::class)); $mountManager->addMount($mount); $this->assertEquals([$mount], $mountManager->findByStorageId('dummy')); |