123 hook.set_operation(entity._cw, 'bfss_added', fpath, AddFileOp) |
123 hook.set_operation(entity._cw, 'bfss_added', fpath, AddFileOp) |
124 return binary |
124 return binary |
125 |
125 |
126 def entity_updated(self, entity, attr): |
126 def entity_updated(self, entity, attr): |
127 """an entity using this storage for attr has been updatded""" |
127 """an entity using this storage for attr has been updatded""" |
|
128 oldpath = self.current_fs_path(entity, attr) |
128 if entity._cw.transaction_data.get('fs_importing'): |
129 if entity._cw.transaction_data.get('fs_importing'): |
129 oldpath = self.current_fs_path(entity, attr) |
|
130 fpath = entity[attr].getvalue() |
130 fpath = entity[attr].getvalue() |
131 if oldpath != fpath: |
|
132 hook.set_operation(entity._cw, 'bfss_deleted', oldpath, |
|
133 DeleteFileOp) |
|
134 binary = Binary(file(fpath).read()) |
131 binary = Binary(file(fpath).read()) |
135 else: |
132 else: |
136 binary = entity.pop(attr) |
133 binary = entity.pop(attr) |
137 fpath = self.current_fs_path(entity, attr) |
134 fpath = self.new_fs_path(entity, attr) |
138 UpdateFileOp(entity._cw, filepath=fpath, filedata=binary.getvalue()) |
135 UpdateFileOp(entity._cw, filepath=fpath, filedata=binary.getvalue()) |
|
136 if oldpath != fpath: |
|
137 entity[attr] = Binary(fpath) |
|
138 hook.set_operation(entity._cw, 'bfss_deleted', oldpath, |
|
139 DeleteFileOp) |
139 return binary |
140 return binary |
140 |
141 |
141 def entity_deleted(self, entity, attr): |
142 def entity_deleted(self, entity, attr): |
142 """an entity using this storage for attr has been deleted""" |
143 """an entity using this storage for attr has been deleted""" |
143 fpath = self.current_fs_path(entity, attr) |
144 fpath = self.current_fs_path(entity, attr) |