|
@ -11,6 +11,8 @@ base_path = os.path.expanduser( |
|
|
|
|
|
|
|
|
base_url = os.path.expanduser( |
|
|
base_url = os.path.expanduser( |
|
|
"~") + "/frappe-bench/sites/" + site_name + "/public/files" |
|
|
"~") + "/frappe-bench/sites/" + site_name + "/public/files" |
|
|
|
|
|
base_url1 = os.path.expanduser( |
|
|
|
|
|
"~") + "/frappe-bench/sites/" + site_name + "/public" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" Working """ |
|
|
""" Working """ |
|
@ -169,13 +171,18 @@ def append_size_file(): |
|
|
""" 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: |
|
|
try: |
|
|
try: |
|
|
file_path = base_url + d.get("file_url") |
|
|
file_path = base_url1 + d.get("file_url") |
|
|
file_size = os.path.getsize(file_path) |
|
|
isExist=os.path.exists(file_path) |
|
|
frappe.db.sql( |
|
|
if isExist: |
|
|
f'''UPDATE `tabFile` SET file_size = '{file_size}' WHERE name = '{d['name']}'; ''', as_dict=1) |
|
|
file_size = os.path.getsize(file_path) |
|
|
frappe.db.commit() |
|
|
frappe.db.sql( |
|
|
except: |
|
|
f'''UPDATE `tabFile` SET file_size = '{file_size}' WHERE name = '{d['name']}'; ''', as_dict=1) |
|
|
pass |
|
|
frappe.db.commit() |
|
|
|
|
|
else: |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
|
|
return str(e) |
|
|
return data |
|
|
return data |
|
|
except Exception as e: |
|
|
except Exception as e: |
|
|
frappe.log_error("FIle size ", str(e)) |
|
|
frappe.log_error("FIle size ", str(e)) |
|
|