Ejemplo n.º 1
0
    def validate_state(self):
        check_version(self.params.version)
        if self.last_sync_log:
            if self.params.state_hash:
                parsed_hash = CaseStateHash.parse(self.params.state_hash)
                computed_hash = self.last_sync_log.get_state_hash()
                if computed_hash != parsed_hash:
                    # log state error on the sync log
                    self.last_sync_log.had_state_error = True
                    self.last_sync_log.error_date = datetime.utcnow()
                    self.last_sync_log.error_hash = str(parsed_hash)
                    self.last_sync_log.save()

                    exception = BadStateException(
                        server_hash=computed_hash,
                        phone_hash=parsed_hash,
                        case_ids=self.last_sync_log.
                        get_footprint_of_cases_on_phone())
                    if self.last_sync_log.log_format == LOG_FORMAT_SIMPLIFIED:
                        from corehq.apps.reports.standard.deployments import SyncHistoryReport
                        _assert = soft_assert(to=['czue' + '@' + 'dimagi.com'])
                        sync_history_url = '{}?individual={}'.format(
                            SyncHistoryReport.get_url(self.domain),
                            self.user.user_id)
                        _assert(
                            False, '{}, sync history report: {}'.format(
                                exception, sync_history_url))
                    raise exception
Ejemplo n.º 2
0
    def validate_state(self):
        check_version(self.params.version)
        if self.last_sync_log:
            if self.params.state_hash:
                parsed_hash = CaseStateHash.parse(self.params.state_hash)
                computed_hash = self.last_sync_log.get_state_hash()
                if computed_hash != parsed_hash:
                    # log state error on the sync log
                    self.last_sync_log.had_state_error = True
                    self.last_sync_log.error_date = datetime.utcnow()
                    self.last_sync_log.error_hash = str(parsed_hash)
                    self.last_sync_log.save()

                    raise BadStateException(server_hash=computed_hash,
                                            phone_hash=parsed_hash,
                                            case_ids=self.last_sync_log.
                                            get_footprint_of_cases_on_phone())
Ejemplo n.º 3
0
    def validate_state(self):
        check_version(self.params.version)
        if self.last_sync_log:
            if (self._case_sync == CLEAN_OWNERS and
                    self.last_sync_log.log_format == LOG_FORMAT_LIVEQUERY):
                raise RestoreException("clean_owners sync after livequery sync")
            if self.params.state_hash:
                parsed_hash = CaseStateHash.parse(self.params.state_hash)
                computed_hash = self.last_sync_log.get_state_hash()
                if computed_hash != parsed_hash:
                    # log state error on the sync log
                    self.last_sync_log.had_state_error = True
                    self.last_sync_log.error_date = datetime.utcnow()
                    self.last_sync_log.error_hash = str(parsed_hash)
                    self.last_sync_log.save()

                    raise BadStateException(
                        server_hash=computed_hash,
                        phone_hash=parsed_hash,
                        case_ids=self.last_sync_log.get_footprint_of_cases_on_phone()
                    )