Skip to content

Commit b3ca186

Browse files
authored
Merge pull request #34020 from nextcloud/logical-op
Switch logical operators (and|or)
2 parents 703dd64 + 5300f0d commit b3ca186

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

lib/private/Files/Storage/Wrapper/Quota.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function getQuota(): int {
6767
}
6868
$this->quota = $quotaCallback();
6969
}
70+
7071
return $this->quota;
7172
}
7273

@@ -84,18 +85,14 @@ protected function getSize($path, $storage = null) {
8485
if ($rootInfo) {
8586
return $rootInfo->getSize(true);
8687
}
87-
return \OCP\Files\FileInfo::SPACE_NOT_COMPUTED;
88+
return FileInfo::SPACE_NOT_COMPUTED;
8889
} else {
89-
if (is_null($storage)) {
90-
$cache = $this->getCache();
91-
} else {
92-
$cache = $storage->getCache();
93-
}
90+
$cache = is_null($storage) ? $this->getCache() : $storage->getCache();
9491
$data = $cache->get($path);
95-
if ($data instanceof ICacheEntry and isset($data['size'])) {
92+
if ($data instanceof ICacheEntry && isset($data['size'])) {
9693
return $data['size'];
9794
} else {
98-
return \OCP\Files\FileInfo::SPACE_NOT_COMPUTED;
95+
return FileInfo::SPACE_NOT_COMPUTED;
9996
}
10097
}
10198
}
@@ -115,16 +112,12 @@ public function free_space($path) {
115112
} else {
116113
$used = $this->getSize($this->sizeRoot);
117114
if ($used < 0) {
118-
return \OCP\Files\FileInfo::SPACE_NOT_COMPUTED;
115+
return FileInfo::SPACE_NOT_COMPUTED;
119116
} else {
120117
$free = $this->storage->free_space($path);
121118
$quotaFree = max($this->getQuota() - $used, 0);
122119
// if free space is known
123-
if ($free >= 0) {
124-
$free = min($free, $quotaFree);
125-
} else {
126-
$free = $quotaFree;
127-
}
120+
$free = $free >= 0 ? min($free, $quotaFree) : $quotaFree;
128121
return $free;
129122
}
130123
}
@@ -142,7 +135,7 @@ public function file_put_contents($path, $data) {
142135
return $this->storage->file_put_contents($path, $data);
143136
}
144137
$free = $this->free_space($path);
145-
if ($free < 0 or strlen($data) < $free) {
138+
if ($free < 0 || strlen($data) < $free) {
146139
return $this->storage->file_put_contents($path, $data);
147140
} else {
148141
return false;
@@ -161,7 +154,7 @@ public function copy($source, $target) {
161154
return $this->storage->copy($source, $target);
162155
}
163156
$free = $this->free_space($target);
164-
if ($free < 0 or $this->getSize($source) < $free) {
157+
if ($free < 0 || $this->getSize($source) < $free) {
165158
return $this->storage->copy($source, $target);
166159
} else {
167160
return false;
@@ -191,6 +184,7 @@ public function fopen($path, $mode) {
191184
}
192185
}
193186
}
187+
194188
return $source;
195189
}
196190

@@ -225,7 +219,7 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
225219
return $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
226220
}
227221
$free = $this->free_space($targetInternalPath);
228-
if ($free < 0 or $this->getSize($sourceInternalPath, $sourceStorage) < $free) {
222+
if ($free < 0 || $this->getSize($sourceInternalPath, $sourceStorage) < $free) {
229223
return $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
230224
} else {
231225
return false;
@@ -243,7 +237,7 @@ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
243237
return $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
244238
}
245239
$free = $this->free_space($targetInternalPath);
246-
if ($free < 0 or $this->getSize($sourceInternalPath, $sourceStorage) < $free) {
240+
if ($free < 0 || $this->getSize($sourceInternalPath, $sourceStorage) < $free) {
247241
return $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
248242
} else {
249243
return false;

0 commit comments

Comments
 (0)