-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- download relevant data is sent per POST, a token is received - download is started by GET and the received token - solves the disadvantages from XHR-only download - job to cleanup download tokens Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
- Loading branch information
Showing
7 changed files
with
138 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
declare(strict_types=1); | ||
/** | ||
* @copyright Copyright (c) 2021 Arthur Schiwon <blizzz@arthur-schiwon.de> | ||
* | ||
* @author Arthur Schiwon <blizzz@arthur-schiwon.de> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OCA\files\lib\BackgroundJob; | ||
|
||
use OC\BackgroundJob\TimedJob; | ||
use OCA\Files\AppInfo\Application; | ||
use OCP\IConfig; | ||
|
||
class CleanupDownloadTokens extends TimedJob { | ||
private const INTERVAL_MINUTES = 24 * 60; | ||
/** @var IConfig */ | ||
private $config; | ||
|
||
public function __construct(IConfig $config) { | ||
$this->interval = self::INTERVAL_MINUTES; | ||
$this->config = $config; | ||
} | ||
|
||
protected function run($argument) { | ||
$appKeys = $this->config->getAppKeys(Application::APP_ID); | ||
foreach ($appKeys as $key) { | ||
if (strpos($key, Application::DL_TOKEN_PREFIX) !== 0) { | ||
continue; | ||
} | ||
$dataStr = $this->config->getAppValue(Application::APP_ID, $key, ''); | ||
if ($dataStr === '') { | ||
$this->config->deleteAppValue(Application::APP_ID, $key); | ||
continue; | ||
} | ||
$data = \json_decode($dataStr, true); | ||
if (!isset($data['lastActivity']) || (time() - $data['lastActivity']) > 24 * 60 * 2) { | ||
// deletes tokens that have not seen activity for 2 days | ||
// the period is chosen to allow continue of downloads with network interruptions in minde | ||
$this->config->deleteAppValue(Application::APP_ID, $key); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters