Skip to content

Commit

Permalink
Add save method to upload data manager so saving data can be defered to
Browse files Browse the repository at this point in the history
  after commit hook
  • Loading branch information
vangheem committed Mar 26, 2018
1 parent d6adac2 commit f7b523b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.rst
@@ -1,7 +1,12 @@
2.5.10 (unreleased)
-------------------

- Nothing changed yet.
- Make sure to clear commit hook on tcp begin
[vangheem]

- Add save method to upload data manager so saving data can be defered to
after commit hook
[vangheem]


2.5.9 (2018-03-22)
Expand Down
4 changes: 3 additions & 1 deletion guillotina/db/transaction.py
Expand Up @@ -197,7 +197,6 @@ async def _call_after_commit_hooks(self, status=True):
logger.error("Error in after commit hook exec in %s ",
hook, exc_info=sys.exc_info())
self._after_commit = []
self._before_commit = []

# BEGIN TXN
async def tpc_begin(self):
Expand All @@ -207,6 +206,9 @@ async def tpc_begin(self):
"""
self._txn_time = time.time()
await self._strategy.tpc_begin()
# make sure this is reset on retries
self._after_commit = []
self._before_commit = []

def check_read_only(self):
if self.request is None:
Expand Down
3 changes: 3 additions & 0 deletions guillotina/files/adapter.py
Expand Up @@ -73,6 +73,9 @@ async def update(self, **kwargs):
self._data.update(kwargs)
self.context._p_register()

async def save(self, **kwargs):
pass

async def finish(self, values=None):
# create file object with new data from finished upload
file = self.field.get(self.real_context)
Expand Down
3 changes: 3 additions & 0 deletions guillotina/files/manager.py
Expand Up @@ -142,6 +142,8 @@ async def tus_patch(self, *args, **kwargs):
await self.file_storage_manager.finish(self.dm)
await self.dm.finish()
headers['Tus-Upload-Finished'] = '1'
else:
await self.dm.save()

resp = Response(headers=headers)
return resp
Expand Down Expand Up @@ -196,6 +198,7 @@ async def tus_create(self, *args, **kwargs):
offset=0)

await self.file_storage_manager.start(self.dm)
await self.dm.save()

# Location will need to be adapted on aiohttp 1.1.x
resp = Response(headers={
Expand Down

0 comments on commit f7b523b

Please sign in to comment.