Browse Source
Merge pull request #54401 from nextcloud/fix/streamer-directory-mtime
fix(ZipFolderPlugin): set mtime of directories in archive
pull/54411/head
Andy Scherzinger
4 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
12 additions and
6 deletions
-
apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php
-
lib/private/Streamer.php
|
|
|
@ -67,15 +67,16 @@ class ZipFolderPlugin extends ServerPlugin { |
|
|
|
// 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(), $node->getMTime()); |
|
|
|
$streamer->addFileFromStream($resource, $filename, $node->getSize(), $mtime); |
|
|
|
} elseif ($node instanceof NcFolder) { |
|
|
|
$streamer->addEmptyDir($filename); |
|
|
|
$streamer->addEmptyDir($filename, $mtime); |
|
|
|
$content = $node->getDirectoryListing(); |
|
|
|
foreach ($content as $subNode) { |
|
|
|
$this->streamNode($streamer, $subNode, $rootPath); |
|
|
|
|
|
|
|
@ -170,11 +170,16 @@ class Streamer { |
|
|
|
/** |
|
|
|
* Add an empty directory entry to the archive. |
|
|
|
* |
|
|
|
* @param string $dirName Directory Path and name to be added to the archive. |
|
|
|
* @return bool $success |
|
|
|
* @param $dirName - Directory Path and name to be added to the archive. |
|
|
|
* @param $timestamp - Modification time of the directory (defaults to current time) |
|
|
|
*/ |
|
|
|
public function addEmptyDir($dirName) { |
|
|
|
return $this->streamerInstance->addEmptyDir($dirName); |
|
|
|
public function addEmptyDir(string $dirName, int $timestamp = 0): bool { |
|
|
|
$options = null; |
|
|
|
if ($timestamp > 0) { |
|
|
|
$options = ['timestamp' => $timestamp]; |
|
|
|
} |
|
|
|
|
|
|
|
return $this->streamerInstance->addEmptyDir($dirName, $options); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|