nextcloud/server · error · Sabre\DAV\Exception\ServiceUnavailable

Requested file can currently not be accessed.

Error message

Requested file can currently not be accessed.

What it means

ZipFolderPlugin::streamNode() (apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php:85) throws ServiceUnavailable (HTTP 503) when $node->fopen('rb') returns false while building the streamed ZIP of a folder download (GET on a collection with zip streaming enabled). The node was listed and passed permission checks, but opening it for reading failed — so the archive cannot be completed and the stream is aborted mid-download.

Source

Thrown at apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php:85

		$this->server->on('method:GET', $this->handleDownload(...), 100);
		// low priority to give any other afterMethod:* a chance to fire before we cancel everything
		$this->server->on('afterMethod:GET', $this->afterDownload(...), 999);
	}

	/**
	 * Adding a node to the archive streamer.
	 * This will recursively add new nodes to the stream if the node is a directory.
	 */
	protected function streamNode(Streamer $streamer, NcNode $node, string $rootPath): void {
		// Remove the root path from the filename to make it relative to the requested folder
		$filename = str_replace($rootPath, '', $node->getPath());

		$mtime = $node->getMTime();
		if ($node instanceof NcFile) {
			$resource = $node->fopen('rb');
			if ($resource === false) {
				$this->logger->info('Cannot read file for zip stream', ['filePath' => $node->getPath()]);
				throw new \Sabre\DAV\Exception\ServiceUnavailable('Requested file can currently not be accessed.');
			}
			$streamer->addFileFromStream($resource, $filename, $node->getSize(), $mtime);
		} elseif ($node instanceof NcFolder) {
			$streamer->addEmptyDir($filename, $mtime);
			$content = $node->getDirectoryListing();
			foreach ($content as $subNode) {
				$this->streamNode($streamer, $subNode, $rootPath);
			}
		}
	}

	/**
	 * Download a folder as an archive.
	 * It is possible to filter / limit the files that should be downloaded,
	 * either by passing (multiple) `X-NC-Files: the-file` headers
	 * or by setting a `files=JSON_ARRAY_OF_FILES` URL query.
	 */
	public function handleDownload(Request $request, Response $response): ?false {

View on GitHub (pinned to ecdeb153ff)

Solutions

  1. Retry the folder download — if a file was transiently locked/unreadable, a second attempt often succeeds.
  2. Identify the unreadable file: the server log line 'Cannot read file for zip stream' with filePath pinpoints it; then open that single file directly (GET) to see its specific error.
  3. Fix or remove the offending file (restore permissions, repair the mount, delete a corrupt entry), then re-download the folder.
  4. As a workaround, download files individually or exclude the broken subtree from the ZIP request.
Defensive patterns

Strategy: fallback

Validate before calling

// before zipping, verify each file is readable
foreach ($folder->getDirectoryListing() as $node) {
    if ($node instanceof \OCP\Files\File && !$node->isReadable()) {
        $this->logger->warning('Skipping unreadable file in zip', ['path' => $node->getPath()]);
        continue;
    }
    $this->streamNode($streamer, $node, $rootPath);
}

Try / catch

try {
    $this->streamNode($streamer, $node, $rootPath);
} catch (\Sabre\DAV\Exception\ServiceUnavailable $e) {
    $this->logger->warning('Skipping unreadable file in folder zip', ['filePath' => $node->getPath()]);
    // fallback: skip the single file and finish the archive rather than aborting the whole download
}

Prevention

When it happens

Trigger: Downloading a folder as ZIP (GET /remote.php/dav/files/user/folder or the zip-download route) where at least one contained file cannot be opened: underlying file unreadable on the storage, permissions changed since listing, external storage glitch, or the file removed between listing and streaming.

Common situations: Folder downloads containing a file on a flaky external mount; a file whose read is denied by ACL/group-folder rules applied at open time; antivirus or ransomware-protection locking files during the zip; very large folders where state changes mid-stream.

Related errors


AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17). Data as JSON: /api/errors/7a4fc9527cb3d507. Report an issue: GitHub.