<s> import frappe <EOL> def execute ( ) : <EOL> from frappe . core . doctype . file . file import make_home_folder <EOL> if not frappe . db . exists ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> frappe . rename_doc ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> frappe . reload_doctype ( "<STR_LIT>" ) <EOL> if not frappe . db . exists ( "<STR_LIT>" , { "<STR_LIT>" : <NUM_LIT:1> } ) : <EOL> make_home_folder ( ) <EOL> for file in frappe . get_all ( "<STR_LIT>" , filters = { "<STR_LIT>" : <NUM_LIT:0> } ) : <EOL> file = frappe . get_doc ( "<STR_LIT>" , file . name ) <EOL> file . flags . ignore_folder_validate = True <EOL> file . flags . ignore_file_validate = True <EOL> file . flags . ignore_duplicate_entry_error = True <EOL> file . flags . ignore_links = True <EOL> file . set_folder_name ( ) <EOL> try : <EOL> file . save ( ) <EOL> except : <EOL> print frappe . get_traceback ( ) <EOL> raise <EOL> from frappe . utils . nestedset import rebuild_tree <EOL> rebuild_tree ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> for folder in frappe . db . sql ( """<STR_LIT>""" ) : <EOL> folder = frappe . get_doc ( "<STR_LIT>" , folder [ <NUM_LIT:0> ] ) <EOL> folder . save ( ) </s>
