Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions apps/dav/lib/BackgroundJob/UploadCleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\Server;
use Psr\Log\LoggerInterface;

class UploadCleanup extends TimedJob {
Expand Down Expand Up @@ -47,8 +49,9 @@ protected function run($argument) {
return;
}

// Remove if all files have an mtime of more than a day
$time = $this->time->getTime() - 60 * 60 * 24;
// Remove if all files have an mtime of more than a day or configured TTL
$ttl = Server::get(IConfig::class)->getSystemValueInt('cache_chunk_gc_ttl', 60 * 60 * 24);
$time = $this->time->getTime() - $ttl;

if (!($uploadFolder instanceof Folder)) {
$this->logger->error('Found a file inside the uploads folder. Uid: ' . $uid . ' folder: ' . $folder);
Expand All @@ -61,8 +64,6 @@ protected function run($argument) {

/** @var File[] $files */
$files = $uploadFolder->getDirectoryListing();

// The folder has to be more than a day old
$initial = $uploadFolder->getMTime() < $time;

$expire = array_reduce($files, function (bool $carry, File $file) use ($time) {
Expand Down
6 changes: 3 additions & 3 deletions lib/private/Cache/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ public function clear($prefix = '') {
public function gc() {
$storage = $this->getStorage();
if ($storage) {
// extra hour safety, in case of stray part chunks that take longer to write,
// because touch() is only called after the chunk was finished
$now = time() - 3600;
$ttl = \OC::$server->getConfig()->getSystemValueInt('cache_chunk_gc_ttl', 60 * 60 * 24);
$now = time() - $ttl;

$dh = $storage->opendir('/');
if (!is_resource($dh)) {
return null;
Expand Down
Loading