server/sources/storages.py
branchstable
changeset 5183 8d66003351f8
parent 5131 88b5ca8da928
child 5218 aebd00a2d316
equal deleted inserted replaced
5182:3bc8250731fe 5183:8d66003351f8
    83             AddFileOp(entity._cw, filepath=fpath)
    83             AddFileOp(entity._cw, filepath=fpath)
    84         return binary
    84         return binary
    85 
    85 
    86     def entity_updated(self, entity, attr):
    86     def entity_updated(self, entity, attr):
    87         """an entity using this storage for attr has been updatded"""
    87         """an entity using this storage for attr has been updatded"""
    88         binary = entity.pop(attr)
    88         if entity._cw.transaction_data.get('fs_importing'):
    89         fpath = self.current_fs_path(entity, attr)
    89             oldpath = self.current_fs_path(entity, attr)
    90         UpdateFileOp(entity._cw, filepath=fpath, filedata=binary.getvalue())
    90             fpath = entity[attr].getvalue()
       
    91             if oldpath != fpath:
       
    92                 DeleteFileOp(entity._cw, filepath=oldpath)
       
    93             binary = Binary(file(fpath).read())
       
    94         else:
       
    95             binary = entity.pop(attr)
       
    96             fpath = self.current_fs_path(entity, attr)
       
    97             UpdateFileOp(entity._cw, filepath=fpath, filedata=binary.getvalue())
    91         return binary
    98         return binary
    92 
    99 
    93     def entity_deleted(self, entity, attr):
   100     def entity_deleted(self, entity, attr):
    94         """an entity using this storage for attr has been deleted"""
   101         """an entity using this storage for attr has been deleted"""
    95         DeleteFileOp(entity._cw, filepath=self.current_fs_path(entity, attr))
   102         DeleteFileOp(entity._cw, filepath=self.current_fs_path(entity, attr))