Browse Source

File Size append to file list

master
venkataakhil 2 years ago
parent
commit
9c17425a0a
  1. 19
      smart_service/apis/master_api.py

19
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
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

Loading…
Cancel
Save