aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/type/detection.php35
-rw-r--r--lib/private/files/view.php97
-rw-r--r--lib/private/http/client/client.php2
-rw-r--r--lib/private/lock/dblockingprovider.php36
-rw-r--r--lib/private/security/certificatemanager.php2
-rw-r--r--lib/private/server.php4
-rw-r--r--lib/private/updater.php7
7 files changed, 106 insertions, 77 deletions
diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php
index 3dc3975fb2a..0c647ab44c6 100644
--- a/lib/private/files/type/detection.php
+++ b/lib/private/files/type/detection.php
@@ -49,15 +49,22 @@ class Detection implements IMimeTypeDetector {
private $urlGenerator;
/** @var string */
- private $configDir;
+ private $customConfigDir;
+
+ /** @var string */
+ private $defaultConfigDir;
/**
* @param IURLGenerator $urlGenerator
- * @param string $configDir
+ * @param string $customConfigDir
+ * @param string $defaultConfigDir
*/
- public function __construct(IURLGenerator $urlGenerator, $configDir) {
+ public function __construct(IURLGenerator $urlGenerator,
+ $customConfigDir,
+ $defaultConfigDir) {
$this->urlGenerator = $urlGenerator;
- $this->configDir = $configDir;
+ $this->customConfigDir = $customConfigDir;
+ $this->defaultConfigDir = $defaultConfigDir;
}
/**
@@ -71,7 +78,9 @@ class Detection implements IMimeTypeDetector {
* @param string $mimetype
* @param string|null $secureMimeType
*/
- public function registerType($extension, $mimetype, $secureMimeType = null) {
+ public function registerType($extension,
+ $mimetype,
+ $secureMimeType = null) {
$this->mimetypes[$extension] = array($mimetype, $secureMimeType);
$this->secureMimeTypes[$mimetype] = $secureMimeType ?: $mimetype;
}
@@ -102,10 +111,10 @@ class Detection implements IMimeTypeDetector {
return;
}
- $this->mimeTypeAlias = json_decode(file_get_contents($this->configDir . '/mimetypealiases.dist.json'), true);
+ $this->mimeTypeAlias = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypealiases.dist.json'), true);
- if (file_exists($this->configDir . '/mimetypealiases.json')) {
- $custom = json_decode(file_get_contents($this->configDir . '/mimetypealiases.json'), true);
+ if (file_exists($this->customConfigDir . '/mimetypealiases.json')) {
+ $custom = json_decode(file_get_contents($this->customConfigDir . '/mimetypealiases.json'), true);
$this->mimeTypeAlias = array_merge($this->mimeTypeAlias, $custom);
}
}
@@ -126,15 +135,15 @@ class Detection implements IMimeTypeDetector {
return;
}
- $mimetypemapping = json_decode(file_get_contents($this->configDir . '/mimetypemapping.dist.json'), true);
+ $mimetypeMapping = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypemapping.dist.json'), true);
//Check if need to load custom mappings
- if (file_exists($this->configDir . '/mimetypemapping.json')) {
- $custom = json_decode(file_get_contents($this->configDir . '/mimetypemapping.json'), true);
- $mimetypemapping = array_merge($mimetypemapping, $custom);
+ if (file_exists($this->customConfigDir . '/mimetypemapping.json')) {
+ $custom = json_decode(file_get_contents($this->customConfigDir . '/mimetypemapping.json'), true);
+ $mimetypeMapping = array_merge($mimetypeMapping, $custom);
}
- $this->registerTypeArray($mimetypemapping);
+ $this->registerTypeArray($mimetypeMapping);
}
/**
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 9afa9d40b20..c04ca2ef461 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -759,59 +759,72 @@ class View {
$this->lockFile($path2, ILockingProvider::LOCK_SHARED);
$this->lockFile($path1, ILockingProvider::LOCK_SHARED);
+ $lockTypePath1 = ILockingProvider::LOCK_SHARED;
+ $lockTypePath2 = ILockingProvider::LOCK_SHARED;
- $exists = $this->file_exists($path2);
- if ($this->shouldEmitHooks()) {
- \OC_Hook::emit(
- Filesystem::CLASSNAME,
- Filesystem::signal_copy,
- array(
- Filesystem::signal_param_oldpath => $this->getHookPath($path1),
- Filesystem::signal_param_newpath => $this->getHookPath($path2),
- Filesystem::signal_param_run => &$run
- )
- );
- $this->emit_file_hooks_pre($exists, $path2, $run);
- }
- if ($run) {
- $mount1 = $this->getMount($path1);
- $mount2 = $this->getMount($path2);
- $storage1 = $mount1->getStorage();
- $internalPath1 = $mount1->getInternalPath($absolutePath1);
- $storage2 = $mount2->getStorage();
- $internalPath2 = $mount2->getInternalPath($absolutePath2);
-
- $this->changeLock($path2, ILockingProvider::LOCK_EXCLUSIVE);
-
- if ($mount1->getMountPoint() == $mount2->getMountPoint()) {
- if ($storage1) {
- $result = $storage1->copy($internalPath1, $internalPath2);
- } else {
- $result = false;
- }
- } else {
- $result = $storage2->copyFromStorage($storage1, $internalPath1, $internalPath2);
- }
-
- $this->updater->update($path2);
-
- $this->changeLock($path2, ILockingProvider::LOCK_SHARED);
+ try {
- if ($this->shouldEmitHooks() && $result !== false) {
+ $exists = $this->file_exists($path2);
+ if ($this->shouldEmitHooks()) {
\OC_Hook::emit(
Filesystem::CLASSNAME,
- Filesystem::signal_post_copy,
+ Filesystem::signal_copy,
array(
Filesystem::signal_param_oldpath => $this->getHookPath($path1),
- Filesystem::signal_param_newpath => $this->getHookPath($path2)
+ Filesystem::signal_param_newpath => $this->getHookPath($path2),
+ Filesystem::signal_param_run => &$run
)
);
- $this->emit_file_hooks_post($exists, $path2);
+ $this->emit_file_hooks_pre($exists, $path2, $run);
}
+ if ($run) {
+ $mount1 = $this->getMount($path1);
+ $mount2 = $this->getMount($path2);
+ $storage1 = $mount1->getStorage();
+ $internalPath1 = $mount1->getInternalPath($absolutePath1);
+ $storage2 = $mount2->getStorage();
+ $internalPath2 = $mount2->getInternalPath($absolutePath2);
+
+ $this->changeLock($path2, ILockingProvider::LOCK_EXCLUSIVE);
+ $lockTypePath2 = ILockingProvider::LOCK_EXCLUSIVE;
+
+ if ($mount1->getMountPoint() == $mount2->getMountPoint()) {
+ if ($storage1) {
+ $result = $storage1->copy($internalPath1, $internalPath2);
+ } else {
+ $result = false;
+ }
+ } else {
+ $result = $storage2->copyFromStorage($storage1, $internalPath1, $internalPath2);
+ }
- $this->unlockFile($path2, ILockingProvider::LOCK_SHARED);
- $this->unlockFile($path1, ILockingProvider::LOCK_SHARED);
+ $this->updater->update($path2);
+
+ $this->changeLock($path2, ILockingProvider::LOCK_SHARED);
+ $lockTypePath2 = ILockingProvider::LOCK_SHARED;
+
+ if ($this->shouldEmitHooks() && $result !== false) {
+ \OC_Hook::emit(
+ Filesystem::CLASSNAME,
+ Filesystem::signal_post_copy,
+ array(
+ Filesystem::signal_param_oldpath => $this->getHookPath($path1),
+ Filesystem::signal_param_newpath => $this->getHookPath($path2)
+ )
+ );
+ $this->emit_file_hooks_post($exists, $path2);
+ }
+
+ }
+ } catch (\Exception $e) {
+ $this->unlockFile($path2, $lockTypePath2);
+ $this->unlockFile($path1, $lockTypePath1);
+ throw $e;
}
+
+ $this->unlockFile($path2, $lockTypePath2);
+ $this->unlockFile($path1, $lockTypePath1);
+
}
return $result;
}
diff --git a/lib/private/http/client/client.php b/lib/private/http/client/client.php
index b0aff10a413..1907937e55e 100644
--- a/lib/private/http/client/client.php
+++ b/lib/private/http/client/client.php
@@ -62,7 +62,7 @@ class Client implements IClient {
$dataDir = $this->config->getSystemValue('datadirectory');
$this->client->setDefaultOption('verify', $dataDir.'/'.$this->certificateManager->getCertificateBundle());
} else {
- $this->client->setDefaultOption('verify', \OC::$SERVERROOT . '/config/ca-bundle.crt');
+ $this->client->setDefaultOption('verify', \OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
}
$this->client->setDefaultOption('headers/User-Agent', 'ownCloud Server Crawler');
diff --git a/lib/private/lock/dblockingprovider.php b/lib/private/lock/dblockingprovider.php
index bfa86a6920e..a08357a6024 100644
--- a/lib/private/lock/dblockingprovider.php
+++ b/lib/private/lock/dblockingprovider.php
@@ -58,9 +58,17 @@ class DBLockingProvider extends AbstractLockingProvider {
$this->timeFactory = $timeFactory;
}
- protected function initLockField($path) {
+ /**
+ * Insert a file locking row if it does not exists.
+ *
+ * @param string $path
+ * @param int $lock
+ * @return int number of inserted rows
+ */
+
+ protected function initLockField($path, $lock = 0) {
$expire = $this->getExpireTime();
- $this->connection->insertIfNotExist('*PREFIX*file_locks', ['key' => $path, 'lock' => 0, 'ttl' => $expire], ['key']);
+ return $this->connection->insertIfNotExist('*PREFIX*file_locks', ['key' => $path, 'lock' => $lock, 'ttl' => $expire], ['key']);
}
/**
@@ -98,18 +106,23 @@ class DBLockingProvider extends AbstractLockingProvider {
$this->logger->warning("Trying to acquire a lock for '$path' while inside a transition");
}
- $this->initLockField($path);
$expire = $this->getExpireTime();
if ($type === self::LOCK_SHARED) {
- $result = $this->connection->executeUpdate(
- 'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` + 1, `ttl` = ? WHERE `key` = ? AND `lock` >= 0',
- [$expire, $path]
- );
+ $result = $this->initLockField($path,1);
+ if ($result <= 0) {
+ $result = $this->connection->executeUpdate (
+ 'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` + 1, `ttl` = ? WHERE `key` = ? AND `lock` >= 0',
+ [$expire, $path]
+ );
+ }
} else {
- $result = $this->connection->executeUpdate(
- 'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = 0',
- [$expire, $path]
- );
+ $result = $this->initLockField($path,-1);
+ if ($result <= 0) {
+ $result = $this->connection->executeUpdate(
+ 'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = 0',
+ [$expire, $path]
+ );
+ }
}
if ($result !== 1) {
throw new LockedException($path);
@@ -122,7 +135,6 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
*/
public function releaseLock($path, $type) {
- $this->initLockField($path);
if ($type === self::LOCK_SHARED) {
$this->connection->executeUpdate(
'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` - 1 WHERE `key` = ? AND `lock` > 0',
diff --git a/lib/private/security/certificatemanager.php b/lib/private/security/certificatemanager.php
index 4d470f69a66..ded81863a73 100644
--- a/lib/private/security/certificatemanager.php
+++ b/lib/private/security/certificatemanager.php
@@ -110,7 +110,7 @@ class CertificateManager implements ICertificateManager {
}
// Append the default certificates
- $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/config/ca-bundle.crt');
+ $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
fwrite($fh_certs, $defaultCertificates);
fclose($fh_certs);
}
diff --git a/lib/private/server.php b/lib/private/server.php
index d5f4f532c1c..9f99ead849b 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -470,7 +470,9 @@ class Server extends SimpleContainer implements IServerContainer {
$this->registerService('MimeTypeDetector', function(Server $c) {
return new \OC\Files\Type\Detection(
$c->getURLGenerator(),
- \OC::$configDir);
+ \OC::$SERVERROOT . '/config/',
+ \OC::$SERVERROOT . '/resources/config/'
+ );
});
$this->registerService('MimeTypeLoader', function(Server $c) {
return new \OC\Files\Type\Loader(
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 71e9732c307..b33180c3425 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -279,13 +279,6 @@ class Updater extends BasicEmitter {
throw new \Exception($e->getMessage());
}
- // FIXME: Some users do not upload the new ca-bundle.crt, let's catch this
- // in the update. For a newer release we shall use an integrity check after
- // the update.
- if(!file_exists(\OC::$configDir .'/ca-bundle.crt')) {
- throw new \Exception('Please upload the ca-bundle.crt file into the \'config\' directory.');
- }
-
// create empty file in data dir, so we can later find
// out that this is indeed an ownCloud data directory
// (in case it didn't exist before)