X Tutup
Skip to content

Commit a0f94c8

Browse files
author
Jan Ackermann
authored
Merge pull request #38819 from owncloud/smb_faster_innactive_log
Check a local attribute for the SMB log switch instead
2 parents 7cfe5b6 + 8a27d75 commit a0f94c8

File tree

2 files changed

+21
-3
lines changed
  • apps/files_external/lib/Lib/Storage
  • changelog/unreleased

2 files changed

+21
-3
lines changed

apps/files_external/lib/Lib/Storage/SMB.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
use OCP\Util;
5555

5656
class SMB extends StorageAdapter {
57+
/** @var bool */
58+
protected $logActive;
59+
5760
/**
5861
* @var IServer
5962
*/
@@ -75,6 +78,11 @@ class SMB extends StorageAdapter {
7578
protected $statCache;
7679

7780
public function __construct($params) {
81+
// log switch might be set already (from a subclass), so don't change it.
82+
if (!isset($this->logActive)) {
83+
$this->logActive = \OC::$server->getConfig()->getSystemValue('smb.logging.enable', false) === true;
84+
}
85+
7886
$loggedParams = $params;
7987
// remove password from log if it is set
8088
if (!empty($loggedParams['password'])) {
@@ -743,7 +751,7 @@ public function test() {
743751
* @param string $from
744752
*/
745753
private function log($message, $level = Util::DEBUG, $from = 'smb') {
746-
if (\OC::$server->getConfig()->getSystemValue('smb.logging.enable', false) === true) {
754+
if ($this->logActive) {
747755
Util::writeLog($from, $message, $level);
748756
}
749757
}
@@ -757,7 +765,7 @@ private function log($message, $level = Util::DEBUG, $from = 'smb') {
757765
* @return mixed
758766
*/
759767
private function leave($function, $result) {
760-
if (\OC::$server->getConfig()->getSystemValue('smb.logging.enable', false) === false) {
768+
if (!$this->logActive) {
761769
//don't bother building log strings
762770
return $result;
763771
} elseif ($result === true) {
@@ -780,7 +788,7 @@ private function leave($function, $result) {
780788
}
781789

782790
private function swallow($function, \Exception $exception) {
783-
if (\OC::$server->getConfig()->getSystemValue('smb.logging.enable', false) === true) {
791+
if ($this->logActive) {
784792
Util::writeLog('smb', "$function swallowing ".\get_class($exception)
785793
.' - code: '.$exception->getCode()
786794
.' message: '.$exception->getMessage()

changelog/unreleased/38819

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Enhancement: Improve performance of the SMB log when it is inactive
2+
3+
The SMB connector includes very verbose logs to trace what could have
4+
gone wrong. These logs are disabled by default, but although they're disabled
5+
we still need to check the state to decide whether we want to log or not.
6+
7+
Now, the state check is faster and it takes less time to decide, so the
8+
overall performance of the connector is improved.
9+
10+
https://github.com/owncloud/core/pull/38819

0 commit comments

Comments
 (0)
X Tutup