Skip to content

Commit c10acfb

Browse files
committed
special handling for non-existant .meta files
1 parent 53103f4 commit c10acfb

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

src/Server.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,12 +543,16 @@ private function getRequestedMimeType($accept)
543543
private function handleReadRequest(Response $response, string $path, $contents, $mime=''): Response
544544
{
545545
$filesystem = $this->filesystem;
546-
547546
if ($path === "/") { // FIXME: this is a patch to make it work for Solid-Nextcloud; we should be able to just list '/';
548547
$contents = $this->listDirectoryAsTurtle($path);
549548
$response->getBody()->write($contents);
550549
$response = $response->withHeader("Content-type", "text/turtle");
551550
$response = $response->withStatus(200);
551+
} elseif(($filesystem->has($path) === false) && (($path == ".meta") || ($path == "/.meta"))) {
552+
$contents = '';
553+
$response->getBody()->write($contents);
554+
$response = $response->withHeader("Content-type", "text/turtle");
555+
$response = $response->withStatus(200);
552556
} elseif ($filesystem->has($path) === false && $this->hasDescribedBy($path) === false) {
553557
/*/ The file does not exist and no link-metadata is present /*/
554558
$message = vsprintf(self::ERROR_PATH_DOES_NOT_EXIST, [$path]);
@@ -579,10 +583,18 @@ private function handleReadRequest(Response $response, string $path, $contents,
579583
$response->getBody()->write($contents);
580584
$response = $response->withHeader("Content-type", $mimetype)->withStatus(200);
581585
} else {
582-
/*/ The file does exist in another format and no link-metadata is present /*/
583-
$message = vsprintf(self::ERROR_PATH_DOES_NOT_EXIST, [$path]);
584-
$response->getBody()->write($message);
585-
$response = $response->withStatus(404);
586+
// FIXME: we should not get here if the file does not exist, but here we are. It looks like $filesystem->has("/.meta") always returns true even if the file does not exist;
587+
if ($path == "/.meta") {
588+
$contents = '';
589+
$response->getBody()->write($contents);
590+
$response = $response->withHeader("Content-type", "text/turtle");
591+
$response = $response->withStatus(200);
592+
} else {
593+
/*/ The file does exist in another format and no link-metadata is present /*/
594+
$message = vsprintf(self::ERROR_PATH_DOES_NOT_EXIST, [$path]);
595+
$response->getBody()->write($message);
596+
$response = $response->withStatus(404);
597+
}
586598
}
587599
} else {
588600
/*/ The file does exist in another format and no link-metadata is present /*/

0 commit comments

Comments
 (0)