Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds background job to cleanup all previews. #2152

Merged
merged 2 commits into from
Nov 30, 2016
Merged

Conversation

rullzer
Copy link
Member

@rullzer rullzer commented Nov 16, 2016

  • A repair step that inserts a background job for each user
  • Each background job will delete for 15 seconds if it takes longer we
    reschedule. This is done so instances that don't use the system cron
    won't time out.

CC: @MorrisJobke @nickvergessen @icewind1991 @LukasReschke

@rullzer rullzer added the 3. to review Waiting for reviews label Nov 16, 2016
@rullzer rullzer added this to the Nextcloud 11.0 milestone Nov 16, 2016
@mention-bot
Copy link

@rullzer, thanks for your PR! By analyzing the history of the files in this pull request, we identified @LukasReschke, @DeepDiver1975 and @PVince81 to be potential reviewers.

@icewind1991
Copy link
Member

tests?

@rullzer
Copy link
Member Author

rullzer commented Nov 16, 2016

Yes I still want that. but testing is a bitch because DI doesn't work for core stuff there 😕

@rullzer rullzer force-pushed the preview_cleanupjob branch 3 times, most recently from fa61b98 to 059d5af Compare November 16, 2016 18:00
@rullzer
Copy link
Member Author

rullzer commented Nov 16, 2016

Tests added

@icewind1991
Copy link
Member

👍

@codecov-io
Copy link

codecov-io commented Nov 16, 2016

Current coverage is 57.75% (diff: 75.00%)

Merging #2152 into master will increase coverage by 0.01%

@@             master      #2152   diff @@
==========================================
  Files          1176       1178     +2   
  Lines         70737      70798    +61   
  Methods        7213       7220     +7   
  Messages          0          0          
  Branches       1212       1212          
==========================================
+ Hits          40846      40890    +44   
- Misses        29891      29908    +17   
  Partials          0          0          

Powered by Codecov. Last update b1ee986...78a318d

$c->getRootFolder(),
$c->getLogger(),
$c->getJobList(),
new TimeFactory()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should just register a service ITimeFactory::class, then CleanPreviewsBackgroundJob can be build by the 👾

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect it to be able to auto inject an ITimeFactory already

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only for apps, since it's only defined in DIContainer not in Server

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope won't work because it is not an App. So indeed no DIContainaer which means the DI magic fails.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but when you create it for ITimeFactory it should work

@MorrisJobke
Copy link
Member

cc @icewind1991

@MorrisJobke
Copy link
Member

@nickvergessen @rullzer What are the next steps here?

@rullzer
Copy link
Member Author

rullzer commented Nov 18, 2016

DI fails here with the ITimeFactory after a quick test. I vote to get it in. we can redo DI magic later.

public function run(IOutput $output) {
$this->userManager->callForSeenUsers(function(IUser $user) {
$this->jobList->add(CleanPreviewsBackgroundJob::class, ['uid' => $user->getUID()]);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a check if this was already added? Otherwise this is added on every update. Just add an entry to appconfig 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough... done

* A repair step that inserts a background job for each user
* Each background job will delete for 15 seconds if it takes longer we
reschedule. This is done so instances that don't use the system cron
won't time out.
* Added tests

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
@rullzer rullzer dismissed stale reviews from nickvergessen and MorrisJobke November 30, 2016 07:55

Lets fix it separatly

@MorrisJobke
Copy link
Member

Tested and still works 👍

@MorrisJobke MorrisJobke merged commit 62ec31e into master Nov 30, 2016
@MorrisJobke MorrisJobke deleted the preview_cleanupjob branch November 30, 2016 09:39
@MorrisJobke MorrisJobke mentioned this pull request Dec 1, 2016
47 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants