Browse Source

file size updated

master
venkataakhil 1 year ago
parent
commit
4061df55a5
  1. 21
      smart_service/apis/support.py

21
smart_service/apis/support.py

@ -11,6 +11,8 @@ base_path = os.path.expanduser(
base_url = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public/files"
base_url1 = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
""" Working """
@ -169,13 +171,18 @@ def append_size_file():
""" SELECT * FROM `tabFile` where file_size = 0 and is_folder!=1; """, as_dict=1)
for d in data:
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
file_path = base_url1 + d.get("file_url")
isExist=os.path.exists(file_path)
if isExist:
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()
else:
pass
except Exception as e:
return str(e)
return data
except Exception as e:
frappe.log_error("FIle size ", str(e))

Loading…
Cancel
Save