Skip to content

Commit 43a9632

Browse files
committed
Set the file's mtime from the headers in bulk upload
Signed-off-by: Louis Chemineau <[email protected]>
1 parent 130d3bd commit 43a9632

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

apps/dav/lib/BulkUpload/BulkUploadPlugin.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Psr\Log\LoggerInterface;
2626
use Sabre\DAV\Server;
2727
use Sabre\DAV\ServerPlugin;
28+
use Sabre\DAV\Exception\BadRequest;
2829
use Sabre\HTTP\RequestInterface;
2930
use Sabre\HTTP\ResponseInterface;
3031
use OCP\Files\Folder;
@@ -78,7 +79,15 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
7879
}
7980

8081
try {
82+
$mtime = strtotime($headers['x-file-mtime']);
83+
84+
if ($mtime === false) {
85+
throw new BadRequest('Error while parsing the mtime.', Http::STATUS_BAD_REQUEST, $e);
86+
}
87+
8188
$node = $this->userFolder->newFile($headers['x-file-path'], $content);
89+
$node->touch($mtime);
90+
8291
$writtenFiles[$headers['x-file-path']] = [
8392
"error" => false,
8493
"etag" => $node->getETag(),

0 commit comments

Comments
 (0)