Skip to content

Commit

Permalink
Store record of previous file data on upload
Browse files Browse the repository at this point in the history
  • Loading branch information
vangheem committed Mar 1, 2018
1 parent 2c588f5 commit cae8db6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
@@ -1,7 +1,8 @@
2.3.30 (unreleased)
-------------------

- Nothing changed yet.
- Store record of previous file data on upload
[vangheem]


2.3.29 (2018-03-01)
Expand Down
10 changes: 10 additions & 0 deletions guillotina/files/dbfile.py
Expand Up @@ -6,6 +6,8 @@
from guillotina.interfaces import IFileCleanup
from zope.interface import implementer

import uuid


@implementer(IDBFile)
class DBFile(BaseCloudFile):
Expand All @@ -19,6 +21,13 @@ def valid(self):

async def init_upload(self, context):
context._p_register()

self._old_uri = self.uri
self._old_size = self.size
self._old_filename = self.filename
self._old_md5 = self.md5
self._old_content_type = self.guess_content_type()

self._current_upload = 0
if self._blob is not None:
cleanup = IFileCleanup(context, None)
Expand All @@ -28,6 +37,7 @@ async def init_upload(self, context):
else:
self._previous_blob = self._blob
blob = Blob(context)
self._uri = uuid.uuid4().hex
self._blob = blob

async def append_data(self, context, data):
Expand Down

0 comments on commit cae8db6

Please sign in to comment.