1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
7
|
|
|
* |
8
|
|
|
* @author Lukas Reschke <[email protected]> |
9
|
|
|
* @author Morris Jobke <[email protected]> |
10
|
|
|
* @author Robin Appelman <[email protected]> |
11
|
|
|
* @author Roeland Jago Douma <[email protected]> |
12
|
|
|
* @author Vincent Petry <[email protected]> |
13
|
|
|
* |
14
|
|
|
* @license AGPL-3.0 |
15
|
|
|
* |
16
|
|
|
* This code is free software: you can redistribute it and/or modify |
17
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
18
|
|
|
* as published by the Free Software Foundation. |
19
|
|
|
* |
20
|
|
|
* This program is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU Affero General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
26
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
27
|
|
|
* |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
namespace OCP\Lock; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Class LockedException |
34
|
|
|
* |
35
|
|
|
* @package OCP\Lock |
36
|
|
|
* @since 8.1.0 |
37
|
|
|
*/ |
38
|
|
|
class LockedException extends \Exception { |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Locked path |
42
|
|
|
* |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
private $path; |
46
|
|
|
|
47
|
|
|
/** @var string|null */ |
48
|
|
|
private $existingLock; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* LockedException constructor. |
52
|
|
|
* |
53
|
|
|
* @param string $path locked path |
54
|
|
|
* @param \Exception|null $previous previous exception for cascading |
55
|
|
|
* @param string $existingLock since 14.0.0 |
56
|
|
|
* @since 8.1.0 |
57
|
|
|
*/ |
58
|
|
|
public function __construct(string $path, \Exception $previous = null, string $existingLock = null) { |
59
|
|
|
$message = '"' . $path . '" is locked'; |
60
|
|
|
$this->existingLock = $existingLock; |
61
|
|
|
if ($existingLock) { |
62
|
|
|
$message .= ', existing lock on file: ' . $existingLock; |
63
|
|
|
} |
64
|
|
|
parent::__construct($message, 0, $previous); |
65
|
|
|
$this->path = $path; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
* @since 8.1.0 |
71
|
|
|
*/ |
72
|
|
|
public function getPath(): string { |
73
|
|
|
return $this->path; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return string |
78
|
|
|
* @since 19.0.0 |
79
|
|
|
*/ |
80
|
|
|
public function getExistingLock(): ?string { |
81
|
|
|
return $this->existingLock; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|