Closed vartagg closed 7 years ago
As declared in Docs MEDIA_ROOT is "Absolute filesystem path to the directory that will hold user-uploaded files.". And plugin is working with absolute path, even in tests absolute path is using.
Please, can you explain with example what is your problem?
And better to create separate pull requests for different fixes. Easier to review and merge.
I can confirm than I ran the command, and ALL the content of my media folder (not just the the extra files that were properly identified) was deleted... 😱
@akolpakov
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:
images/1/2017/image.jpg
audio/10/2016/foo.mp3
django application directory
or its subdirectories.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.
And better to create separate pull requests for different fixes. Easier to review and merge.
Unfortunately I don't have time for create multiple pull-requests, so I haven't see this condition for contributors in your README file when created my pull-request. I just used your library on a real project, fixing all found bugs, fixing tests for these changes, and sent you feedback with PR. In addition, the library is not that big, and for my opinion multiple pull-requests for every change is overkill.
Thanks @vartagg! I divided it to several commits and implemented everything except optional removing of empty dirs. It will be implemented in #12
MEDIA_ROOT
declared as absolute path. Absolute path ofMEDIA_ROOT
usually always used on server, especially on production environments, and it's confused when command removes all media when I tried this on project having absoluteMEDIA_ROOT
.remove_empty_dirs
optional argument added instead of force usage of this behaviour. I added this because not everyone wants to remove empty dirs. Sometimes it can be useful, sometimes not. In my opinion, it would be good to make this behaviour as optional argument.y
in output but real character is uppercase -Y
install_requires
. I tried this app on my dev and production environments, so it's working well on Django==1.11.