mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 23:03:00 -04:00
Merge pull request #54401 from nextcloud/fix/streamer-directory-mtime
fix(ZipFolderPlugin): set mtime of directories in archive
This commit is contained in:
commit
7d45e9b2a3
2 changed files with 12 additions and 6 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue