diff --git a/smart_service/apis/master_api.py b/smart_service/apis/master_api.py index ad43d4b..a42db67 100644 --- a/smart_service/apis/master_api.py +++ b/smart_service/apis/master_api.py @@ -344,6 +344,7 @@ def change_file_ext(): return False return True + def delete_file_ext(): try: frappe.db.sql(''' @@ -352,4 +353,20 @@ def delete_file_ext(): frappe.db.commit() except: return False - return True \ No newline at end of file + return True + + +@frappe.whitelist(methods=['POST']) +def append_size_file(): + try: + data = frappe.db.sql( + """ SELECT * FROM `tabFile` where file_size = 0 and is_folder!=1; """, as_dict=1) + for d in data: + file_path = base_url + d.get("file_url") + file_size = os.path.getsize(file_path) + frappe.db.sql( + f'''UPDATE `tabFile` SET file_size = '{file_size}' WHERE name = '{d['name']}'; ''', as_dict=1) + frappe.db.commit() + return True + except: + return False