-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update source file details on file change #1760
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -711,13 +711,10 @@ class Meta: | |
abstract = True | ||
|
||
def save(self, *args, **kwargs): | ||
if not self.filename: | ||
self.filename = self.file.name | ||
if not self.size: | ||
self.size = self.file.size | ||
if not self.mimetype: | ||
self.file.seek(0) | ||
self.mimetype = magic.from_buffer(self.file.read(), mime=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this prevents us from updating the source file details There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This messes with setting these fields explicitly. Instead, clear them in the admin form so that they get reset here. |
||
self.filename = self.file.name | ||
self.size = self.file.size | ||
self.file.seek(0) | ||
self.mimetype = magic.from_buffer(self.file.read(), mime=True) | ||
return super().save(*args, **kwargs) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@longhotsummer this is getting called before the source file is saved and updated so we can move it to after the save_related method