akolpakov / django-unused-media

Remove unused media files from Django project
MIT License
124 stars 24 forks source link

If MEDIA_ROOT declared as absolute path, it deleting everything in MEDIA_ROOT #10

Closed vartagg closed 6 years ago

vartagg commented 7 years ago

My PR with fixes #9

beaumartinez commented 6 years ago

Trying to install with Django 1.11 actually uninstalls that version, and installs 1.10.7 instead.

akolpakov commented 6 years ago

@beaumartinez Working with Django 1.11 was fixed by #11 in version 0.1.7, available in PyPi

akolpakov commented 6 years ago

@vartagg Thanks for contribution!

Based on your MR, I made some fixes.

And plugin is working with absolute path, even in tests absolute path is using.

Yes, it is. But unfortunately, tests do not cover this bug. If you test with at least such parameters:

I sure that the last is a key parameter, because I saw in Debugger when images/1/2017/image.jpg (stored in fileobj.url) is comparing with something like ../../../images/1/2017/image.jpg ("relative path" of file provided by os.path module when MEDIA_ROOT path was higher then django application directory in filesystem tree) so comparison function didn't detect this because ../../../images/1/2017/image.jpg is not a real path bound with some django file field object. So, everything in MEDIA_ROOT (after confirmation and on test environment, what is good) is deleted.

akolpakov commented 6 years ago

Fixed in version 0.1.8.