summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-01-15 13:02:15 +0100
committerRobin Appelman <icewind@owncloud.com>2014-01-15 13:02:15 +0100
commit729210daa0a7219966dff7eadedb49f5006fccb0 (patch)
tree0525bcd21ea4b4cfaed0ac13a58b401b73b3c87a /lib
parent5d456c7cc21f7640435c4638932984a52b4cdbac (diff)
parentd1f3f121d6992be07c3600882449ce17d56f116f (diff)
downloadnextcloud-server-729210daa0a7219966dff7eadedb49f5006fccb0.tar.gz
nextcloud-server-729210daa0a7219966dff7eadedb49f5006fccb0.zip
Merge branch 'master' into memcache-public
Conflicts: apps/user_ldap/lib/connection.php
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php4
-rw-r--r--lib/l10n/ru_RU.php12
-rw-r--r--lib/private/api.php42
-rw-r--r--lib/private/connector/sabre/file.php5
-rw-r--r--lib/private/files/cache/cache.php22
-rw-r--r--lib/private/files/cache/scanner.php2
-rw-r--r--lib/private/user.php2
-rw-r--r--lib/private/user/session.php14
-rwxr-xr-xlib/private/util.php2
9 files changed, 56 insertions, 49 deletions
diff --git a/lib/base.php b/lib/base.php
index a8e9e901847..f30575c7b12 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -544,12 +544,12 @@ class OC {
OC_User::useBackend(new OC_User_Database());
OC_Group::useBackend(new OC_Group_Database());
- if (isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('user_id')
+ if (isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('loginname')
&& $_SERVER['PHP_AUTH_USER'] !== self::$session->get('loginname')) {
$sessionUser = self::$session->get('loginname');
$serverUser = $_SERVER['PHP_AUTH_USER'];
OC_Log::write('core',
- "Session user-id ($sessionUser) doesn't match SERVER[PHP_AUTH_USER] ($serverUser).",
+ "Session loginname ($sessionUser) doesn't match SERVER[PHP_AUTH_USER] ($serverUser).",
OC_Log::WARN);
OC_User::logout();
}
diff --git a/lib/l10n/ru_RU.php b/lib/l10n/ru_RU.php
deleted file mode 100644
index 23e900721e8..00000000000
--- a/lib/l10n/ru_RU.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-$TRANSLATIONS = array(
-"Help" => "Помощь",
-"Settings" => "Настройки",
-"Files" => "Файлы",
-"Text" => "Текст",
-"_%n minute ago_::_%n minutes ago_" => array("","",""),
-"_%n hour ago_::_%n hours ago_" => array("","",""),
-"_%n day go_::_%n days ago_" => array("","",""),
-"_%n month ago_::_%n months ago_" => array("","","")
-);
-$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);";
diff --git a/lib/private/api.php b/lib/private/api.php
index 03d7b7382a5..c713368125c 100644
--- a/lib/private/api.php
+++ b/lib/private/api.php
@@ -33,7 +33,7 @@ class OC_API {
const USER_AUTH = 1;
const SUBADMIN_AUTH = 2;
const ADMIN_AUTH = 3;
-
+
/**
* API Response Codes
*/
@@ -41,13 +41,13 @@ class OC_API {
const RESPOND_SERVER_ERROR = 996;
const RESPOND_NOT_FOUND = 998;
const RESPOND_UNKNOWN_ERROR = 999;
-
+
/**
* api actions
*/
protected static $actions = array();
private static $logoutRequired = false;
-
+
/**
* registers an api call
* @param string $method the http method
@@ -58,7 +58,7 @@ class OC_API {
* @param array $defaults
* @param array $requirements
*/
- public static function register($method, $url, $action, $app,
+ public static function register($method, $url, $action, $app,
$authLevel = OC_API::USER_AUTH,
$defaults = array(),
$requirements = array()) {
@@ -75,7 +75,7 @@ class OC_API {
}
self::$actions[$name][] = array('app' => $app, 'action' => $action, 'authlevel' => $authLevel);
}
-
+
/**
* handles an api call
* @param array $parameters
@@ -125,7 +125,7 @@ class OC_API {
self::respond($response, $format);
}
-
+
/**
* merge the returned result objects into one response
* @param array $responses
@@ -166,32 +166,31 @@ class OC_API {
// Maybe any that are not OC_API::RESPOND_SERVER_ERROR
// Merge failed responses if more than one
$data = array();
- $meta = array();
foreach($shipped['failed'] as $failure) {
$data = array_merge_recursive($data, $failure['response']->getData());
}
$picked = reset($shipped['failed']);
$code = $picked['response']->getStatusCode();
- $response = new OC_OCS_Result($data, $code);
+ $meta = $picked['response']->getMeta();
+ $response = new OC_OCS_Result($data, $code, $meta['message']);
return $response;
} elseif(!empty($shipped['succeeded'])) {
$responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']);
} elseif(!empty($thirdparty['failed'])) {
// Merge failed responses if more than one
$data = array();
- $meta = array();
foreach($thirdparty['failed'] as $failure) {
$data = array_merge_recursive($data, $failure['response']->getData());
}
$picked = reset($thirdparty['failed']);
$code = $picked['response']->getStatusCode();
- $response = new OC_OCS_Result($data, $code);
+ $meta = $picked['response']->getMeta();
+ $response = new OC_OCS_Result($data, $code, $meta['message']);
return $response;
} else {
$responses = $thirdparty['succeeded'];
}
// Merge the successful responses
- $meta = array();
$data = array();
foreach($responses as $app => $response) {
@@ -200,22 +199,25 @@ class OC_API {
} else {
$data = array_merge_recursive($data, $response['response']->getData());
}
- $codes[] = $response['response']->getStatusCode();
+ $codes[] = array('code' => $response['response']->getStatusCode(),
+ 'meta' => $response['response']->getMeta());
}
// Use any non 100 status codes
$statusCode = 100;
+ $statusMessage = null;
foreach($codes as $code) {
- if($code != 100) {
- $statusCode = $code;
+ if($code['code'] != 100) {
+ $statusCode = $code['code'];
+ $statusMessage = $code['meta']['message'];
break;
}
}
- $result = new OC_OCS_Result($data, $statusCode);
+ $result = new OC_OCS_Result($data, $statusCode, $statusMessage);
return $result;
}
-
+
/**
* authenticate the api call
* @param array $action the action details as supplied to OC_API::register()
@@ -261,8 +263,8 @@ class OC_API {
return false;
break;
}
- }
-
+ }
+
/**
* http basic auth
* @return string|false (username, or false on failure)
@@ -294,7 +296,7 @@ class OC_API {
return false;
}
-
+
/**
* respond to a call
* @param OC_OCS_Result $result
@@ -343,5 +345,5 @@ class OC_API {
}
}
}
-
+
}
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 53524ec9e54..c3b59007295 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -242,7 +242,10 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
$fileExists = $fs->file_exists($targetPath);
if ($renameOkay === false || $fileExists === false) {
\OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
- $fs->unlink($targetPath);
+ // only delete if an error occurred and the target file was already created
+ if ($fileExists) {
+ $fs->unlink($targetPath);
+ }
throw new Sabre_DAV_Exception();
}
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 8e682a96b75..1e7936ca26d 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -178,7 +178,7 @@ class Cache {
if ($file['storage_mtime'] == 0) {
$file['storage_mtime'] = $file['mtime'];
}
- if ($file['encrypted']) {
+ if ($file['encrypted'] or ($file['unencrypted_size'] > 0 and $file['mimetype'] === 'httpd/unix-directory')) {
$file['encrypted_size'] = $file['size'];
$file['size'] = $file['unencrypted_size'];
}
@@ -511,22 +511,34 @@ class Cache {
$entry = $this->get($path);
if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
$id = $entry['fileid'];
- $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 FROM `*PREFIX*filecache` '.
+ $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2, ' .
+ 'SUM(`unencrypted_size`) AS f3 ' .
+ 'FROM `*PREFIX*filecache` ' .
'WHERE `parent` = ? AND `storage` = ?';
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
if ($row = $result->fetchRow()) {
- list($sum, $min) = array_values($row);
+ list($sum, $min, $unencryptedSum) = array_values($row);
$sum = (int)$sum;
$min = (int)$min;
+ $unencryptedSum = (int)$unencryptedSum;
if ($min === -1) {
$totalSize = $min;
} else {
$totalSize = $sum;
}
+ $update = array();
if ($entry['size'] !== $totalSize) {
- $this->update($id, array('size' => $totalSize));
+ $update['size'] = $totalSize;
+ }
+ if ($entry['unencrypted_size'] !== $unencryptedSum) {
+ $update['unencrypted_size'] = $unencryptedSum;
+ }
+ if (count($update) > 0) {
+ $this->update($id, $update);
+ }
+ if ($totalSize !== -1 and $unencryptedSum > 0) {
+ $totalSize = $unencryptedSum;
}
-
}
}
return $totalSize;
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index a8c069ee99f..92a4c01841b 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -122,7 +122,7 @@ class Scanner extends BasicEmitter {
$propagateETagChange = true;
}
// only reuse data if the file hasn't explicitly changed
- if (isset($data['mtime']) && isset($cacheData['mtime']) && $data['mtime'] === $cacheData['mtime']) {
+ if (isset($data['storage_mtime']) && isset($cacheData['storage_mtime']) && $data['storage_mtime'] === $cacheData['storage_mtime']) {
if (($reuseExisting & self::REUSE_SIZE) && ($data['size'] === -1)) {
$data['size'] = $cacheData['size'];
}
diff --git a/lib/private/user.php b/lib/private/user.php
index e0d6b9f3f51..98ebebbe5c1 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -246,6 +246,8 @@ class OC_User {
session_regenerate_id(true);
self::setUserId($uid);
self::setDisplayName($uid);
+ self::getUserSession()->setLoginName($uid);
+
OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid, 'password'=>'' ));
return true;
}
diff --git a/lib/private/user/session.php b/lib/private/user/session.php
index c2885d00413..1e299416fb3 100644
--- a/lib/private/user/session.php
+++ b/lib/private/user/session.php
@@ -115,13 +115,13 @@ class Session implements Emitter, \OCP\IUserSession {
/**
* set the login name
*
- * @param string login name for the logged in user
+ * @param string $loginName for the logged in user
*/
- public function setLoginname($loginname) {
- if (is_null($loginname)) {
+ public function setLoginName($loginName) {
+ if (is_null($loginName)) {
$this->session->remove('loginname');
} else {
- $this->session->set('loginname', $loginname);
+ $this->session->set('loginname', $loginName);
}
}
@@ -130,7 +130,7 @@ class Session implements Emitter, \OCP\IUserSession {
*
* @return string
*/
- public function getLoginname() {
+ public function getLoginName() {
if ($this->activeUser) {
return $this->session->get('loginname');
} else {
@@ -158,7 +158,7 @@ class Session implements Emitter, \OCP\IUserSession {
if (!is_null($user)) {
if ($user->isEnabled()) {
$this->setUser($user);
- $this->setLoginname($uid);
+ $this->setLoginName($uid);
$this->manager->emit('\OC\User', 'postLogin', array($user, $password));
return true;
} else {
@@ -176,7 +176,7 @@ class Session implements Emitter, \OCP\IUserSession {
public function logout() {
$this->manager->emit('\OC\User', 'logout');
$this->setUser(null);
- $this->setLoginname(null);
+ $this->setLoginName(null);
$this->unsetMagicInCookie();
}
diff --git a/lib/private/util.php b/lib/private/util.php
index c0e618cc863..a4b3761dbd3 100755
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -580,7 +580,7 @@ class OC_Util {
// Check if we are a user
if( !OC_User::isLoggedIn()) {
header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php',
- array('redirectUrl' => OC_Request::requestUri())
+ array('redirect_url' => OC_Request::requestUri())
));
exit();
}