Skip to content

Add ckan user clean command #7241

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

Merged
merged 12 commits into from
Dec 7, 2022
Merged

Add ckan user clean command #7241

merged 12 commits into from
Dec 7, 2022

Conversation

pdelboca
Copy link
Member

@pdelboca pdelboca commented Nov 26, 2022

Fixes #7225 part of #7208

Proposed fixes:

This PR adds a new command ckan clean users that will scan the system for users with invalid images and delete both the image and the user from the database.

Invalid images are all images that doesn't contain allowed mimetypes set in ckan.upload.user.mimetypes config option.

Features:

  • includes tests covering changes
  • includes updated documentation
  • includes user-visible changes
  • includes API changes
  • includes bugfix for possible backport

Please [X] all the boxes above that apply

@pdelboca
Copy link
Member Author

For now I'm trying to keep a logic that do not delete the user if the image cannot be deleted. (Permission issues, ..., ?) This is to avoid leaving unreferenced images in the store.

@pdelboca
Copy link
Member Author

The second issue I'm getting is that this logic is aggressive and considers a user account as spam if they have a wrong file in the image.

What about false positives? What if the administrator forgets one mimetype?

@pdelboca pdelboca marked this pull request as ready for review December 5, 2022 12:34
@amercader amercader self-assigned this Dec 6, 2022
Copy link
Member

@amercader amercader left a comment

Choose a reason for hiding this comment

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

Looks good @pdelboca only one minor tweak

pdelboca and others added 2 commits December 7, 2022 17:04
@pdelboca
Copy link
Member Author

pdelboca commented Dec 7, 2022

Done @amercader !

Failing Cypress test seems unrelated.

@amercader amercader merged commit e12df07 into ckan:master Dec 7, 2022
@amercader
Copy link
Member

amercader commented Dec 22, 2022

@pdelboca I ported this to dev-v2.9 in bd8ec0c but I'm getting a failure in one of the tests

pytest --ckan-ini=test-core-custom.ini -v -s --disable-warnings ckan/tests/cli/test_clean.py::TestUserClean::test_output_if_there_are_not_invalid_users```

Can you see if you can find what's wrong?

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

Successfully merging this pull request may close these issues.

User clean up command
2 participants