def setStorageItem(self, instance, name, value): """Sets an item into ES storage area. """ if instance.isTemporary(): return # check for old item to perform a move/copy filepath = os.path.join(self.getRootPath(), value.get('filepath')) old_item = self.getStorageItem(instance, name) if old_item: old_filepath = os.path.join(self.getRootPath(), old_item.get('filepath')) if not old_filepath == filepath and os.path.exists(old_filepath): if not getattr(instance, '_v_copying', False): os.remove(old_filepath) ExternalStorage.setStorageItem(self, instance, name, value) self.recursiveDelete(os.path.dirname(old_filepath)) return ExternalStorage.setStorageItem(self, instance, name, value)