If the defendant is not arrested on a warrant from the proper county, as provided in section 1115, he must be discharged from custody, or his bail in the action is exonerated, or money deposited instead of bail must be refunded to him or to the person or persons found by the court to have deposited said money on behalf of said defendant, as the case may be, and the sureties in the undertaking, as mentioned in that section, must be discharged. If he is arrested, the same proceedings must be had thereon as upon the arrest of a defendant in another county on a warrant of arrest issued by a magistrate.