Skip to content

Background cleanup job for system and user tag orphaned when file was deleted - #21990

Merged
DeepDiver1975 merged 1 commit into
masterfrom
systemtags-cleanup-orphans
Jan 29, 2016
Merged

DeepDiver1975 merged 1 commit into
masterfrom
systemtags-cleanup-orphans

Conversation

@PVince81

Copy link
Copy Markdown
Contributor

Whenever a file was deleted (also from trash), the tag mapping is
pointing at a fileid that doesn't exist any more.

This cleanup job will delete such orphaned mapping entries.

This applies for BOTH system tags and user tags (like favorite).

To test:

  1. Create a file "test.txt" in the web UI
  2. Inspect the "tr" element to find its "data-id" (the file id)
  3. Mark the file "test.txt" as favorite
  4. Add a system tag "test1" to this file using the right sidebar
  5. select * from oc_vcategory_to_object where objid=$fileid => 1 result
  6. select * from oc_systemtag_object_mapping where objectid=$fileid => 1 result
  7. Delete the file "test.txt"
  8. Empty trashbin
  9. Reset the cleanup job: update oc_jobs set last_run=0 where class='OCA\\Files\\Lib\\DeleteOrphanedTagsJob'
  10. Run "cron.php"
  11. Rerun the two selects from above: no results

Please review @nickvergessen @icewind1991 @rullzer @blizzz

@PVince81 PVince81 added this to the 9.0-current milestone Jan 28, 2016
@mention-bot

Copy link
Copy Markdown

By analyzing the blame information on this pull request, we identified @LukasReschke, @nickvergessen and @MorrisJobke to be potential reviewers

@PVince81

Copy link
Copy Markdown
Contributor Author

Oh, looks like we had a repair step that did something similar for user tags: #13344

Maybe we should remove the repair step too ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Once a day should be enough?

@PVince81

Copy link
Copy Markdown
Contributor Author

Oh, looks like we had a repair step that did something similar for user tags #13344

@nickvergessen what do you think ? From what I saw you wrote it 😄

@nickvergessen
nickvergessen force-pushed the systemtags-cleanup-orphans branch 2 times, most recently from ae488b6 to 75dd8a0 Compare January 29, 2016 10:49
@nickvergessen

Copy link
Copy Markdown
Contributor
  • Moved the file into the right subfolder of the app
  • Fixed the test to be a unit test instead of an integration test
  • Split the method into two, for better testing

Still works, 👍 for the actual code (which I didn't touch apart from the splitting)

Whenever a file was deleted (also from trash), the tag mapping is
pointing at a fileid that doesn't exist any more.

This cleanup job will delete such orphaned mapping entries.
@MorrisJobke

Copy link
Copy Markdown
Contributor

Tested and works 👍

DeepDiver1975 added a commit that referenced this pull request Jan 29, 2016
Background cleanup job for system and user tag orphaned when file was deleted
@DeepDiver1975
DeepDiver1975 merged commit e8c4496 into master Jan 29, 2016
@DeepDiver1975
DeepDiver1975 deleted the systemtags-cleanup-orphans branch January 29, 2016 13:16
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants