(a) Any lien provided for by this chapter shall be enforced in the same manner as provided in Chapter 4 (commencing with Section 8400) of Title 2 of Part 6 of Division 4 of the Civil Code. The action shall be filed within 180 days from the time of the recording of the lien. If a credit is given and notice of the fact and terms of the credit is filed in the office of the county recorder subsequent to the filing of the lien and prior to the expiration of the 180-day period, then the lien continues in force until 180 days after the expiration of the credit, but no lien continues in force by reason of any agreement to give credit for a longer time than one year from the time the work is completed. If the proceedings to enforce the lien are not
prosecuted to trial within two years after commencement, the court may in its discretion dismiss the action for want of prosecution, and in all cases the dismissal of the action (unless it is expressly stated that it is without prejudice) or a judgment in the action that no lien exists is equivalent to the cancellation and removal from the record of the lien.
(b) As against any purchaser or encumbrancer for value and in good faith whose rights are acquired subsequent to the expiration of the 180-day period following the filing of the lien, no giving of credit or extension of the lien or time to enforce the lien shall be effective unless evidenced by a notice or agreement filed for record in the office of the county recorder prior to the acquisition of the rights of the purchaser or encumbrancer.