sehmaschine / django-filebrowser

Media-Management with Grappelli
http://twitter.com/sehmaschine
Other
976 stars 408 forks source link

Post upload signal sends wrong fileobject if file already exists #392

Closed dteskera closed 3 years ago

dteskera commented 3 years ago

bug is in sites.py _upload_file method in line 598 it gets the wrong file_name if its overwriting existing file

possible fix: in sites.py change lines https://github.com/sehmaschine/django-filebrowser/blob/master/filebrowser/sites.py#L588 https://github.com/sehmaschine/django-filebrowser/blob/master/filebrowser/sites.py#L592 so that you get fileobject instead of full_path f = FileObject(smart_str(old_file), site=self) and f = FileObject(smart_str(file_name), site=self)

then change line https://github.com/sehmaschine/django-filebrowser/blob/master/filebrowser/sites.py#L596 os.chmod(f.path_full, DEFAULT_PERMISSIONS)

and then you can remove line https://github.com/sehmaschine/django-filebrowser/blob/master/filebrowser/sites.py#L598

P.S. sorry i cant fork it and make a pull request since i already have a fork of a fork that i need to keep.

jakov-kanaet commented 3 years ago

Pull request: https://github.com/sehmaschine/django-filebrowser/pull/393

sehmaschine commented 3 years ago

thanks. merged the PR.