mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-05 22:48:27 +00:00
fix: reposting issue with s3 backup
(cherry picked from commit 6b454ca9a7)
This commit is contained in:
committed by
Mergify
parent
6301b321d8
commit
73c1bf972e
@@ -405,6 +405,22 @@ def create_json_gz_file(data, doc, file_name=None) -> str:
|
|||||||
compressed_content = gzip.compress(encoded_content)
|
compressed_content = gzip.compress(encoded_content)
|
||||||
|
|
||||||
if not file_name:
|
if not file_name:
|
||||||
|
return create_file(doc, compressed_content)
|
||||||
|
else:
|
||||||
|
file_doc = frappe.get_doc("File", file_name)
|
||||||
|
if "/frappe_s3_attachment." in file_doc.file_url:
|
||||||
|
file_doc.delete()
|
||||||
|
return create_file(doc, compressed_content)
|
||||||
|
|
||||||
|
path = file_doc.get_full_path()
|
||||||
|
|
||||||
|
with open(path, "wb") as f:
|
||||||
|
f.write(compressed_content)
|
||||||
|
|
||||||
|
return doc.reposting_data_file
|
||||||
|
|
||||||
|
|
||||||
|
def create_file(doc, compressed_content):
|
||||||
json_filename = f"{scrub(doc.doctype)}-{scrub(doc.name)}.json.gz"
|
json_filename = f"{scrub(doc.doctype)}-{scrub(doc.name)}.json.gz"
|
||||||
_file = frappe.get_doc(
|
_file = frappe.get_doc(
|
||||||
{
|
{
|
||||||
@@ -420,14 +436,6 @@ def create_json_gz_file(data, doc, file_name=None) -> str:
|
|||||||
_file.save(ignore_permissions=True)
|
_file.save(ignore_permissions=True)
|
||||||
|
|
||||||
return _file.file_url
|
return _file.file_url
|
||||||
else:
|
|
||||||
file_doc = frappe.get_doc("File", file_name)
|
|
||||||
path = file_doc.get_full_path()
|
|
||||||
|
|
||||||
with open(path, "wb") as f:
|
|
||||||
f.write(compressed_content)
|
|
||||||
|
|
||||||
return doc.reposting_data_file
|
|
||||||
|
|
||||||
|
|
||||||
def get_items_to_be_repost(voucher_type=None, voucher_no=None, doc=None, reposting_data=None):
|
def get_items_to_be_repost(voucher_type=None, voucher_no=None, doc=None, reposting_data=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user