server/sources/storages.py
changeset 8662 60a13447f389
parent 8544 3d049071957e
child 8695 358d8bed9626
equal deleted inserted replaced
8661:4d24ac49f90d 8662:60a13447f389
   150 
   150 
   151     def entity_added(self, entity, attr):
   151     def entity_added(self, entity, attr):
   152         """an entity using this storage for attr has been added"""
   152         """an entity using this storage for attr has been added"""
   153         if entity._cw.transaction_data.get('fs_importing'):
   153         if entity._cw.transaction_data.get('fs_importing'):
   154             binary = Binary.from_file(entity.cw_edited[attr].getvalue())
   154             binary = Binary.from_file(entity.cw_edited[attr].getvalue())
       
   155             entity._cw_dont_cache_attribute(attr, repo_side=True)
   155         else:
   156         else:
   156             binary = entity.cw_edited.pop(attr)
   157             binary = entity.cw_edited.pop(attr)
   157             fpath = self.new_fs_path(entity, attr)
   158             fpath = self.new_fs_path(entity, attr)
   158             # bytes storage used to store file's path
   159             # bytes storage used to store file's path
   159             entity.cw_edited.edited_attribute(attr, Binary(fpath))
   160             entity.cw_edited.edited_attribute(attr, Binary(fpath))
   168         if entity._cw.transaction_data.get('fs_importing'):
   169         if entity._cw.transaction_data.get('fs_importing'):
   169             # If we are importing from the filesystem, the file already exists.
   170             # If we are importing from the filesystem, the file already exists.
   170             # We do not need to create it but we need to fetch the content of
   171             # We do not need to create it but we need to fetch the content of
   171             # the file as the actual content of the attribute
   172             # the file as the actual content of the attribute
   172             fpath = entity.cw_edited[attr].getvalue()
   173             fpath = entity.cw_edited[attr].getvalue()
       
   174             entity._cw_dont_cache_attribute(attr, repo_side=True)
   173             assert fpath is not None
   175             assert fpath is not None
   174             binary = Binary.from_file(fpath)
   176             binary = Binary.from_file(fpath)
   175         else:
   177         else:
   176             # We must store the content of the attributes
   178             # We must store the content of the attributes
   177             # into a file to stay consistent with the behaviour of entity_add.
   179             # into a file to stay consistent with the behaviour of entity_add.