Skip to content

Commit

Permalink
Set the file's mtime from the headers in bulk upload
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Jan 4, 2022
1 parent 130d3bd commit 43a9632
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apps/dav/lib/BulkUpload/BulkUploadPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Psr\Log\LoggerInterface;
use Sabre\DAV\Server;
use Sabre\DAV\ServerPlugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
use OCP\Files\Folder;
Expand Down Expand Up @@ -78,7 +79,15 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
}

try {
$mtime = strtotime($headers['x-file-mtime']);

if ($mtime === false) {
throw new BadRequest('Error while parsing the mtime.', Http::STATUS_BAD_REQUEST, $e);
}

$node = $this->userFolder->newFile($headers['x-file-path'], $content);
$node->touch($mtime);

$writtenFiles[$headers['x-file-path']] = [
"error" => false,
"etag" => $node->getETag(),
Expand Down

0 comments on commit 43a9632

Please sign in to comment.