Skip to content

Commit 168b07d

Browse files
committed
Lower log to debug for connections aborted by the client
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent cb2a6d6 commit 168b07d

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@
274274
'OCP\\Files\\Config\\IMountProviderCollection' => $baseDir . '/lib/public/Files/Config/IMountProviderCollection.php',
275275
'OCP\\Files\\Config\\IRootMountProvider' => $baseDir . '/lib/public/Files/Config/IRootMountProvider.php',
276276
'OCP\\Files\\Config\\IUserMountCache' => $baseDir . '/lib/public/Files/Config/IUserMountCache.php',
277+
'OCP\\Files\\ConnectionLostException' => $baseDir . '/lib/public/Files/ConnectionLostException.php',
277278
'OCP\\Files\\DavUtil' => $baseDir . '/lib/public/Files/DavUtil.php',
278279
'OCP\\Files\\EmptyFileNameException' => $baseDir . '/lib/public/Files/EmptyFileNameException.php',
279280
'OCP\\Files\\EntityTooLargeException' => $baseDir . '/lib/public/Files/EntityTooLargeException.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
307307
'OCP\\Files\\Config\\IMountProviderCollection' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IMountProviderCollection.php',
308308
'OCP\\Files\\Config\\IRootMountProvider' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IRootMountProvider.php',
309309
'OCP\\Files\\Config\\IUserMountCache' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IUserMountCache.php',
310+
'OCP\\Files\\ConnectionLostException' => __DIR__ . '/../../..' . '/lib/public/Files/ConnectionLostException.php',
310311
'OCP\\Files\\DavUtil' => __DIR__ . '/../../..' . '/lib/public/Files/DavUtil.php',
311312
'OCP\\Files\\EmptyFileNameException' => __DIR__ . '/../../..' . '/lib/public/Files/EmptyFileNameException.php',
312313
'OCP\\Files\\EntityTooLargeException' => __DIR__ . '/../../..' . '/lib/public/Files/EntityTooLargeException.php',

lib/private/Files/View.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
use OCA\Files_Sharing\SharedMount;
5454
use OCP\Constants;
5555
use OCP\Files\Cache\ICacheEntry;
56+
use OCP\Files\ConnectionLostException;
5657
use OCP\Files\EmptyFileNameException;
5758
use OCP\Files\FileNameTooLongException;
5859
use OCP\Files\InvalidCharacterInPathException;
@@ -496,7 +497,7 @@ public function readfilePart($path, $from, $to) {
496497
private function checkConnectionStatus(): void {
497498
$connectionStatus = \connection_status();
498499
if ($connectionStatus !== 0) {
499-
throw new \RuntimeException("Connection lost. Status: $connectionStatus");
500+
throw new ConnectionLostException("Connection lost. Status: $connectionStatus");
500501
}
501502
}
502503

lib/private/legacy/OC_Files.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ public static function get($dir, $files, $params = null) {
233233
OC::$server->getLogger()->logException($ex);
234234
$l = \OC::$server->getL10N('lib');
235235
\OC_Template::printErrorPage($l->t('Cannot download file'), $ex->getMessage(), 200);
236+
} catch (\OCP\Files\ConnectionLostException $ex) {
237+
self::unlockAllTheFiles($dir, $files, $getType, $view, $filename);
238+
OC::$server->getLogger()->logException($ex, ['level' => \OCP\ILogger::DEBUG]);
239+
\OC_Template::printErrorPage('Connection lost', $ex->getMessage(), 200);
236240
} catch (\Exception $ex) {
237241
self::unlockAllTheFiles($dir, $files, $getType, $view, $filename);
238242
OC::$server->getLogger()->logException($ex);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2016, ownCloud, Inc.
4+
*
5+
* @author Côme Chilliet <come.chilliet@nextcloud.com>
6+
*
7+
* @license AGPL-3.0
8+
*
9+
* This code is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License, version 3,
11+
* as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License, version 3,
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>
20+
*
21+
*/
22+
23+
namespace OCP\Files;
24+
25+
/**
26+
* Exception for lost connection with the
27+
* @since 25.0.11
28+
*/
29+
class ConnectionLostException extends \RuntimeException {
30+
}

0 commit comments

Comments
 (0)