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