server/sources/storages.py
changeset 10997 da712d3f0601
parent 10996 dc572d116731
equal deleted inserted replaced
10996:dc572d116731 10997:da712d3f0601
   152 
   152 
   153     def entity_added(self, entity, attr):
   153     def entity_added(self, entity, attr):
   154         """an entity using this storage for attr has been added"""
   154         """an entity using this storage for attr has been added"""
   155         if entity._cw.transaction_data.get('fs_importing'):
   155         if entity._cw.transaction_data.get('fs_importing'):
   156             binary = Binary.from_file(entity.cw_edited[attr].getvalue())
   156             binary = Binary.from_file(entity.cw_edited[attr].getvalue())
   157             entity._cw_dont_cache_attribute(attr)
   157             entity._cw_dont_cache_attribute(attr, repo_side=True)
   158         else:
   158         else:
   159             binary = entity.cw_edited.pop(attr)
   159             binary = entity.cw_edited.pop(attr)
   160             fd, fpath = self.new_fs_path(entity, attr)
   160             fd, fpath = self.new_fs_path(entity, attr)
   161             # bytes storage used to store file's path
   161             # bytes storage used to store file's path
   162             binary_obj = Binary(fpath if PY2 else fpath.encode('utf-8'))
   162             binary_obj = Binary(fpath if PY2 else fpath.encode('utf-8'))
   172         if entity._cw.transaction_data.get('fs_importing'):
   172         if entity._cw.transaction_data.get('fs_importing'):
   173             # If we are importing from the filesystem, the file already exists.
   173             # If we are importing from the filesystem, the file already exists.
   174             # We do not need to create it but we need to fetch the content of
   174             # We do not need to create it but we need to fetch the content of
   175             # the file as the actual content of the attribute
   175             # the file as the actual content of the attribute
   176             fpath = entity.cw_edited[attr].getvalue()
   176             fpath = entity.cw_edited[attr].getvalue()
   177             entity._cw_dont_cache_attribute(attr)
   177             entity._cw_dont_cache_attribute(attr, repo_side=True)
   178             assert fpath is not None
   178             assert fpath is not None
   179             binary = Binary.from_file(fpath)
   179             binary = Binary.from_file(fpath)
   180         else:
   180         else:
   181             # We must store the content of the attributes
   181             # We must store the content of the attributes
   182             # into a file to stay consistent with the behaviour of entity_add.
   182             # into a file to stay consistent with the behaviour of entity_add.