server/sources/storages.py
branchstable
changeset 8300 87c72dccf7b9
parent 8148 b7a195d54fd4
child 8307 8be58694f416
equal deleted inserted replaced
8296:f23782a2cdee 8300:87c72dccf7b9
   173                 # write attribute value on disk
   173                 # write attribute value on disk
   174                 binary.to_file(fpath)
   174                 binary.to_file(fpath)
   175                 # Mark the new file as added during the transaction.
   175                 # Mark the new file as added during the transaction.
   176                 # The file will be removed on rollback
   176                 # The file will be removed on rollback
   177                 AddFileOp.get_instance(entity._cw).add_data(fpath)
   177                 AddFileOp.get_instance(entity._cw).add_data(fpath)
   178         if oldpath != fpath:
   178             # reinstall poped value
   179             # register the new location for the file.
       
   180             if fpath is None:
   179             if fpath is None:
   181                 entity.cw_edited.edited_attribute(attr, None)
   180                 entity.cw_edited.edited_attribute(attr, None)
   182             else:
   181             else:
       
   182                 # register the new location for the file.
   183                 entity.cw_edited.edited_attribute(attr, Binary(fpath))
   183                 entity.cw_edited.edited_attribute(attr, Binary(fpath))
       
   184         if oldpath is not None and oldpath != fpath:
   184             # Mark the old file as useless so the file will be removed at
   185             # Mark the old file as useless so the file will be removed at
   185             # commit.
   186             # commit.
   186             if oldpath is not None:
   187             DeleteFileOp.get_instance(entity._cw).add_data(oldpath)
   187                 DeleteFileOp.get_instance(entity._cw).add_data(oldpath)
       
   188         return binary
   188         return binary
   189 
   189 
   190     def entity_deleted(self, entity, attr):
   190     def entity_deleted(self, entity, attr):
   191         """an entity using this storage for attr has been deleted"""
   191         """an entity using this storage for attr has been deleted"""
   192         fpath = self.current_fs_path(entity, attr)
   192         fpath = self.current_fs_path(entity, attr)