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
@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
try:
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()
except:
pass
except Exception as e:
frappe.log_error("FIle size ", str(e))
return e

Loading…
Cancel
Save