Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix incorrect if conditions in View
($something->getPermissions() && Constants::PERMISSION_READ) does not
  make sense as PERMISSION_READ contant is 1 this will always evaluate to
  true.
getPersmissions is returning an int which is a bitwise combination as
  documented in the interface, so it should be used with bit operators.

Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Apr 5, 2022
commit 916fbe81c6baabb59e7d5444cbc04bf696f679df
6 changes: 3 additions & 3 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ private function basicOperation($operation, $path, $hooks = [], $extraParam = nu
throw $e;
}

if ($result && in_array('delete', $hooks) and $result) {
if ($result && in_array('delete', $hooks)) {
$this->removeUpdate($storage, $internalPath);
}
if ($result && in_array('write', $hooks, true) && $operation !== 'fopen' && $operation !== 'touch') {
Expand Down Expand Up @@ -1450,7 +1450,7 @@ public function getDirectoryContent($directory, $mimetype_filter = '') {

$data = $this->getCacheEntry($storage, $internalPath, $directory);

if (!$data instanceof ICacheEntry || !isset($data['fileid']) || !($data->getPermissions() && Constants::PERMISSION_READ)) {
if (!$data instanceof ICacheEntry || !isset($data['fileid']) || !($data->getPermissions() & Constants::PERMISSION_READ)) {
return [];
}

Expand Down Expand Up @@ -1504,7 +1504,7 @@ public function getDirectoryContent($directory, $mimetype_filter = '') {
$rootEntry = $subCache->get('');
}

if ($rootEntry && ($rootEntry->getPermissions() && Constants::PERMISSION_READ)) {
if ($rootEntry && ($rootEntry->getPermissions() & Constants::PERMISSION_READ)) {
$relativePath = trim(substr($mountPoint, $dirLength), '/');
if ($pos = strpos($relativePath, '/')) {
//mountpoint inside subfolder add size to the correct folder
Expand Down