mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 23:03:00 -04:00
fix(files_trashbin): set real filename on trashbin download
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
parent
e3f575ba7a
commit
441aab68a4
5 changed files with 25 additions and 8 deletions
|
|
@ -42,7 +42,7 @@ To prevent a user from running out of disk space, the Deleted files app will not
|
|||
<collection>OCA\Files_Trashbin\Sabre\RootCollection</collection>
|
||||
</collections>
|
||||
<plugins>
|
||||
<plugin>OCA\Files_Trashbin\Sabre\PropfindPlugin</plugin>
|
||||
<plugin>OCA\Files_Trashbin\Sabre\TrashbinPlugin</plugin>
|
||||
</plugins>
|
||||
</sabre>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ return array(
|
|||
'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => $baseDir . '/../lib/Sabre/AbstractTrashFile.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFolder' => $baseDir . '/../lib/Sabre/AbstractTrashFolder.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\ITrash' => $baseDir . '/../lib/Sabre/ITrash.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\PropfindPlugin' => $baseDir . '/../lib/Sabre/PropfindPlugin.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\RestoreFolder' => $baseDir . '/../lib/Sabre/RestoreFolder.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\RootCollection' => $baseDir . '/../lib/Sabre/RootCollection.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\TrashFile' => $baseDir . '/../lib/Sabre/TrashFile.php',
|
||||
|
|
@ -36,6 +35,7 @@ return array(
|
|||
'OCA\\Files_Trashbin\\Sabre\\TrashFolderFolder' => $baseDir . '/../lib/Sabre/TrashFolderFolder.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\TrashHome' => $baseDir . '/../lib/Sabre/TrashHome.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\TrashRoot' => $baseDir . '/../lib/Sabre/TrashRoot.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\TrashbinPlugin' => $baseDir . '/../lib/Sabre/TrashbinPlugin.php',
|
||||
'OCA\\Files_Trashbin\\Storage' => $baseDir . '/../lib/Storage.php',
|
||||
'OCA\\Files_Trashbin\\Trash\\BackendNotFoundException' => $baseDir . '/../lib/Trash/BackendNotFoundException.php',
|
||||
'OCA\\Files_Trashbin\\Trash\\ITrashBackend' => $baseDir . '/../lib/Trash/ITrashBackend.php',
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ class ComposerStaticInitFiles_Trashbin
|
|||
'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => __DIR__ . '/..' . '/../lib/Sabre/AbstractTrashFile.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFolder' => __DIR__ . '/..' . '/../lib/Sabre/AbstractTrashFolder.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\ITrash' => __DIR__ . '/..' . '/../lib/Sabre/ITrash.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\PropfindPlugin' => __DIR__ . '/..' . '/../lib/Sabre/PropfindPlugin.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\RestoreFolder' => __DIR__ . '/..' . '/../lib/Sabre/RestoreFolder.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\RootCollection' => __DIR__ . '/..' . '/../lib/Sabre/RootCollection.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\TrashFile' => __DIR__ . '/..' . '/../lib/Sabre/TrashFile.php',
|
||||
|
|
@ -51,6 +50,7 @@ class ComposerStaticInitFiles_Trashbin
|
|||
'OCA\\Files_Trashbin\\Sabre\\TrashFolderFolder' => __DIR__ . '/..' . '/../lib/Sabre/TrashFolderFolder.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\TrashHome' => __DIR__ . '/..' . '/../lib/Sabre/TrashHome.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\TrashRoot' => __DIR__ . '/..' . '/../lib/Sabre/TrashRoot.php',
|
||||
'OCA\\Files_Trashbin\\Sabre\\TrashbinPlugin' => __DIR__ . '/..' . '/../lib/Sabre/TrashbinPlugin.php',
|
||||
'OCA\\Files_Trashbin\\Storage' => __DIR__ . '/..' . '/../lib/Storage.php',
|
||||
'OCA\\Files_Trashbin\\Trash\\BackendNotFoundException' => __DIR__ . '/..' . '/../lib/Trash/BackendNotFoundException.php',
|
||||
'OCA\\Files_Trashbin\\Trash\\ITrashBackend' => __DIR__ . '/..' . '/../lib/Trash/ITrashBackend.php',
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
'name' => '__root__',
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => 'd51429a47232bbf46a2be832ecfa711f102da802',
|
||||
'reference' => '3c99b642938e7810ccd05813cda96643a8ee5da5',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../',
|
||||
'aliases' => array(),
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
'__root__' => array(
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => 'd51429a47232bbf46a2be832ecfa711f102da802',
|
||||
'reference' => '3c99b642938e7810ccd05813cda96643a8ee5da5',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../',
|
||||
'aliases' => array(),
|
||||
|
|
|
|||
|
|
@ -27,14 +27,16 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace OCA\Files_Trashbin\Sabre;
|
||||
|
||||
use OCA\DAV\Connector\Sabre\FilesPlugin;
|
||||
use OCP\IPreview;
|
||||
use Sabre\DAV\INode;
|
||||
use Sabre\DAV\PropFind;
|
||||
use Sabre\DAV\Server;
|
||||
use Sabre\DAV\PropFind;
|
||||
use Sabre\DAV\ServerPlugin;
|
||||
use Sabre\HTTP\RequestInterface;
|
||||
use Sabre\HTTP\ResponseInterface;
|
||||
use OCA\DAV\Connector\Sabre\FilesPlugin;
|
||||
|
||||
class PropfindPlugin extends ServerPlugin {
|
||||
class TrashbinPlugin extends ServerPlugin {
|
||||
public const TRASHBIN_FILENAME = '{http://nextcloud.org/ns}trashbin-filename';
|
||||
public const TRASHBIN_ORIGINAL_LOCATION = '{http://nextcloud.org/ns}trashbin-original-location';
|
||||
public const TRASHBIN_DELETION_TIME = '{http://nextcloud.org/ns}trashbin-deletion-time';
|
||||
|
|
@ -56,6 +58,7 @@ class PropfindPlugin extends ServerPlugin {
|
|||
$this->server = $server;
|
||||
|
||||
$this->server->on('propFind', [$this, 'propFind']);
|
||||
$this->server->on('afterMethod:GET', [$this,'httpGet']);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -110,4 +113,18 @@ class PropfindPlugin extends ServerPlugin {
|
|||
return '';
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set real filename on trashbin download
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param ResponseInterface $response
|
||||
*/
|
||||
public function httpGet(RequestInterface $request, ResponseInterface $response): void {
|
||||
$path = $request->getPath();
|
||||
$node = $this->server->tree->getNodeForPath($path);
|
||||
if ($node instanceof ITrash) {
|
||||
$response->addHeader('Content-Disposition', 'attachment; filename="' . $node->getFilename() . '"');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue