mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-03 23:29:15 +02:00
Fixed broken import because of missing transaction
This commit is contained in:
parent
1e2ab3ee06
commit
b5226367a5
7 changed files with 41 additions and 9 deletions
|
@ -1,6 +1,8 @@
|
|||
import os
|
||||
import shutil
|
||||
|
||||
from django.db import transaction
|
||||
|
||||
|
||||
def rename_file(instance, field_name, new_name, allow_missing_file=False):
|
||||
field = getattr(instance, field_name)
|
||||
|
@ -17,3 +19,9 @@ def rename_file(instance, field_name, new_name, allow_missing_file=False):
|
|||
field.name = os.path.join(initial_path, new_name_with_extension)
|
||||
instance.save()
|
||||
return new_name_with_extension
|
||||
|
||||
|
||||
def on_commit(f, *args, **kwargs):
|
||||
return transaction.on_commit(
|
||||
lambda: f(*args, **kwargs)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue