Skip to content

Run cleanup of old upload parts in background job #8759

Closed

Description

@MorrisJobke

Currently the cleanup of the upload folder is run as a login hook:

server/lib/base.php

Lines 808 to 834 in 20f1f75

$userSession->listen('\OC\User', 'postLogin', function () use ($userSession) {
if (!defined('PHPUNIT_RUN')) {
// reset brute force delay for this IP address and username
$uid = \OC::$server->getUserSession()->getUser()->getUID();
$request = \OC::$server->getRequest();
$throttler = \OC::$server->getBruteForceThrottler();
$throttler->resetDelay($request->getRemoteAddress(), 'login', ['user' => $uid]);
}
try {
$cache = new \OC\Cache\File();
$cache->gc();
} catch (\OC\ServerNotAvailableException $e) {
// not a GC exception, pass it on
throw $e;
} catch (\OC\ForbiddenException $e) {
// filesystem blocked for this request, ignore
} catch (\Exception $e) {
// a GC exception should not prevent users from using OC,
// so log the exception
\OC::$server->getLogger()->logException($e, [
'message' => 'Exception when running cache gc.',
'level' => \OCP\Util::WARN,
'app' => 'core',
]);
}
});

We should do this as a background job.

@icewind1991 @rullzer @nickvergessen Opinions?

Should issues like #8753

Activity

  1. added this to the Nextcloud 14 milestone on Mar 9, 2018
  2. rullzer commented on Mar 9, 2018

    @rullzer
    Member

    Yes we should!

  3. self-assigned this
    on Jun 1, 2018
  4. MorrisJobke commented on Jun 25, 2018

    @MorrisJobke
    MemberAuthor

    The problem with this is that it is required to be on login to have a valid user session as it sets up the view.

    @icewind1991 Is there a way to set this up without the current session? Could you point me at some code that does this so I can come up with a first draft of the fix. Would love to have this fixed in 14 finally.

  5. Santobert commented on Oct 23, 2018

    @Santobert

    I noticed a user with more than 20 GB used disk space and a quota of 5 GB. The folder username/uploads needs about 15-20 GB. The command [...] occ files:cleanup doesn't change anything.

    After I have deleted most of his files (he knows about it ;) ), his personal files take about 40 MB. The upload folder is shrunk to 15 GB.

    Does this situation have anything to do with this ticket? How can I clean up the upload folder?

  6. MorrisJobke commented on Oct 24, 2018

    @MorrisJobke
    MemberAuthor

    Does this situation have anything to do with this ticket? How can I clean up the upload folder?

    The user should logout and login again. Then a cleanup is triggered.

  7. added
    1. to develop
    on Dec 8, 2018
  8. MorrisJobke commented on Jan 7, 2019

    @MorrisJobke
    MemberAuthor

    Most of this is addressed in #12227

  9. MorrisJobke commented on Feb 25, 2019

    @MorrisJobke
    MemberAuthor

    Most of this is addressed in #12227

    Let's close it as it is now.

  10. removed their assignment
    on Feb 25, 2019
  11. krakazyabra commented on May 27, 2021

    @krakazyabra

    Hello. Are there any news about this issue? I'm using S3 and, seems, unfinished uploads persist even after logout/login.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    1. to developenhancementmediumtechnical debt

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions