diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php index 11f21eb828e42..caaba22b05fbe 100644 --- a/lib/private/Files/Storage/Wrapper/Encoding.php +++ b/lib/private/Files/Storage/Wrapper/Encoding.php @@ -510,7 +510,9 @@ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t public function getMetaData($path) { $entry = $this->storage->getMetaData($this->findPathToUse($path)); - $entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/'); + if ($entry !== null) { + $entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/'); + } return $entry; } diff --git a/tests/lib/Files/Storage/Wrapper/EncodingTest.php b/tests/lib/Files/Storage/Wrapper/EncodingTest.php index ae6a6ece74261..b50d6f985f186 100644 --- a/tests/lib/Files/Storage/Wrapper/EncodingTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncodingTest.php @@ -240,4 +240,12 @@ public function testNormalizedGetMetaData() { $entry = $this->instance->getMetaData('/test/' . self::NFD_NAME); $this->assertEquals(self::NFC_NAME, $entry['name']); } + + /** + * Regression test of https://github.com/nextcloud/server/issues/50431 + */ + public function testNoMetadata() { + $this->assertNull($this->instance->getMetaData('/test/null')); + } + }