diff --git a/apps/files_trashbin/lib/Trash/TrashItem.php b/apps/files_trashbin/lib/Trash/TrashItem.php index 153625cfb4cc7..10d6d9ef95b46 100644 --- a/apps/files_trashbin/lib/Trash/TrashItem.php +++ b/apps/files_trashbin/lib/Trash/TrashItem.php @@ -99,6 +99,11 @@ public function getStorage() { return $this->fileInfo->getStorage(); } + #[\Override] + public function getStorageId(): int { + return $this->fileInfo->getStorageId(); + } + #[\Override] public function getId() { return $this->fileInfo->getId(); diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php index 92505907584bf..63953084b936c 100644 --- a/lib/private/Files/FileInfo.php +++ b/lib/private/Files/FileInfo.php @@ -162,6 +162,11 @@ public function getMimePart() { return $this->data['mimepart']; } + #[\Override] + public function getStorageId(): int { + return $this->getMountPoint()->getNumericStorageId(); + } + /** * @return string */ diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index 22a36fd583472..a63b6daa2caba 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -159,14 +159,14 @@ public function getStorage() { } /** - * @return string|null + * @return string */ #[\Override] public function getStorageId() { if (!$this->storageId) { $storage = $this->getStorage(); if (is_null($storage)) { - return null; + return 'invalid'; } $this->storageId = $storage->getId(); if (strlen($this->storageId) > 64) { diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php index afa875e6e8388..abfa90f91c713 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -165,6 +165,11 @@ public function getStorage() { return $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] + public function getStorageId(): int { + return $this->__call(__FUNCTION__, func_get_args()); + } + /** * @inheritDoc */ diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 0de86b92efd8e..a2841f9a4c0a7 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -152,6 +152,11 @@ public function getStorage() { return $storage; } + #[\Override] + public function getStorageId(): int { + return $this->getMountPoint()->getNumericStorageId(); + } + /** * @return string */ diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index af5d466a63d4b..6f99618828e2e 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -204,6 +204,11 @@ public function getStorage() { throw new NotFoundException(); } + #[\Override] + public function getStorageId(): int { + throw new NotFoundException(); + } + /** * @return string */ diff --git a/lib/public/Files/FileInfo.php b/lib/public/Files/FileInfo.php index 4d93e57601447..058e02f65ba55 100644 --- a/lib/public/Files/FileInfo.php +++ b/lib/public/Files/FileInfo.php @@ -127,6 +127,15 @@ public function getMimePart(); */ public function getStorage(); + /** + * Get the numeric storage id for the storage backend the file or folder is stored on + * + * @return int + * @throws NotFoundException + * @since 36.0.0 + */ + public function getStorageId(): int; + /** * Get the file id of the file or folder * diff --git a/lib/public/Files/Mount/IMountPoint.php b/lib/public/Files/Mount/IMountPoint.php index ff06021ca888b..171e6aac541c1 100644 --- a/lib/public/Files/Mount/IMountPoint.php +++ b/lib/public/Files/Mount/IMountPoint.php @@ -40,7 +40,7 @@ public function getStorage(); /** * Get the id of the storages * - * @return string|null + * @return string * @since 8.0.0 */ public function getStorageId(); @@ -48,7 +48,7 @@ public function getStorageId(); /** * Get the id of the storages * - * @return int|null + * @return int * @since 9.1.0 */ public function getNumericStorageId(); diff --git a/lib/public/Files/Node.php b/lib/public/Files/Node.php index 727cb2f4da1c0..e45678259ff2a 100644 --- a/lib/public/Files/Node.php +++ b/lib/public/Files/Node.php @@ -75,6 +75,16 @@ public function touch($mtime = null); #[\Override] public function getStorage(); + /** + * Get the numeric storage id for the storage backend the file or folder is stored on + * + * @return int + * @throws NotFoundException + * @since 36.0.0 + */ + #[\Override] + public function getStorageId(): int; + /** * Get the full path of the file or folder * diff --git a/tests/lib/Files/Mount/MountPointTest.php b/tests/lib/Files/Mount/MountPointTest.php index bcbcc96e3a346..80b43da1be78b 100644 --- a/tests/lib/Files/Mount/MountPointTest.php +++ b/tests/lib/Files/Mount/MountPointTest.php @@ -64,7 +64,7 @@ public function testInvalidStorage(): void { // call it again to make sure the init code only ran once $this->assertNull($mountPoint->getStorage()); - $this->assertNull($mountPoint->getStorageId()); + $this->assertEquals('invalid', $mountPoint->getStorageId()); // wrapping doesn't fail $mountPoint->wrapStorage($wrapper);