Skip to content

Commit

Permalink
refactor: forcePermissions typing
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <radialapps@gmail.com>
  • Loading branch information
pulsejet committed Oct 22, 2023
1 parent b3f8387 commit c9e87c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function info(
$info['etag'] = $file->getEtag();

// Inject permissions and convert to string
$info['permissions'] = \OCA\Memories\Util::permissionsToStr($file->getPermissions());
$info['permissions'] = Util::permissionsToStr($file->getPermissions());

// Inject other file parameters that are cheap to get now
$info['mimetype'] = $file->getMimeType();
Expand Down
23 changes: 5 additions & 18 deletions lib/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 +186,6 @@ public static function isLinkSharingEnabled(): bool
return true;
}

/**
* Force a fileinfo value on a node.
* This is a hack to avoid subclassing everything.
*
* @param Node $node File to patch
* @param string $key Key to set
* @param mixed $value Value to set
*/
public static function forceFileInfo(Node &$node, string $key, mixed $value): void
{
/** @var \OC\Files\Node\Node */
$node = $node;

/** @psalm-suppress UndefinedInterfaceMethod */
$node->getFileInfo()[$key] = $value;
}

/**
* Force permissions on a node.
*
Expand All @@ -211,7 +194,11 @@ public static function forceFileInfo(Node &$node, string $key, mixed $value): vo
*/
public static function forcePermissions(Node &$node, int $permissions): void
{
self::forceFileInfo($node, 'permissions', $permissions);
/** @var \OC\Files\Node\Node $node */
$fileInfo = $node->getFileInfo();

/** @var \OC\Files\FileInfo $fileInfo */
$fileInfo['permissions'] = $permissions;
}

/**
Expand Down

0 comments on commit c9e87c4

Please sign in to comment.