Browse Source

Fix error in size file

master
venkataakhil 2 years ago
parent
commit
8209a0ded8
  1. 20
      smart_service/apis/master_api.py

20
smart_service/apis/master_api.py

@ -356,17 +356,19 @@ def delete_file_ext():
return True return True
@frappe.whitelist(methods=['POST'])
def append_size_file(): def append_size_file():
try: try:
data = frappe.db.sql( data = frappe.db.sql(
""" SELECT * FROM `tabFile` where file_size = 0 and is_folder!=1; """, as_dict=1) """ SELECT * FROM `tabFile` where file_size = 0 and is_folder!=1; """, as_dict=1)
for d in data: for d in data:
file_path = base_url + d.get("file_url") try:
file_size = os.path.getsize(file_path) file_path = base_url + d.get("file_url")
frappe.db.sql( file_size = os.path.getsize(file_path)
f'''UPDATE `tabFile` SET file_size = '{file_size}' WHERE name = '{d['name']}'; ''', as_dict=1) frappe.db.sql(
frappe.db.commit() f'''UPDATE `tabFile` SET file_size = '{file_size}' WHERE name = '{d['name']}'; ''', as_dict=1)
return True frappe.db.commit()
except: except:
return False pass
except Exception as e:
frappe.log_error("FIle size ", str(e))
return e

Loading…
Cancel
Save