From 3cd047becfa2f1335320a4c5ec516f54787ab282 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Wed, 13 Apr 2022 19:22:46 +0530 Subject: [PATCH] fix: Obey force kwarg frappe.reload_doc --- frappe/modules/import_file.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/frappe/modules/import_file.py b/frappe/modules/import_file.py index 9cfbe163a5..00483bf6a5 100644 --- a/frappe/modules/import_file.py +++ b/frappe/modules/import_file.py @@ -107,7 +107,6 @@ def import_file_by_path( Returns: [bool]: True if import takes place. False if it wasn't imported. """ - frappe.flags.dt = frappe.flags.dt or [] try: docs = read_doc_from_file(path) except IOError: @@ -121,20 +120,19 @@ def import_file_by_path( docs = [docs] for doc in docs: - # modified timestamp in db, none if doctype's first import db_modified_timestamp = frappe.db.get_value(doc["doctype"], doc["name"], "modified") is_db_timestamp_latest = db_modified_timestamp and ( get_datetime(doc.get("modified")) <= get_datetime(db_modified_timestamp) ) - if not force or db_modified_timestamp: - try: - stored_hash = None - if doc["doctype"] == "DocType": + if not force and db_modified_timestamp: + stored_hash = None + if doc["doctype"] == "DocType": + try: stored_hash = frappe.db.get_value(doc["doctype"], doc["name"], "migration_hash") - except Exception: - frappe.flags.dt += [doc["doctype"]] + except Exception: + pass # if hash exists and is equal no need to update if stored_hash and stored_hash == calculated_hash: @@ -172,12 +170,6 @@ def import_file_by_path( return True -def is_timestamp_changed(doc): - # check if timestamps match - db_modified = frappe.db.get_value(doc["doctype"], doc["name"], "modified") - return not (db_modified and get_datetime(doc.get("modified")) == get_datetime(db_modified)) - - def read_doc_from_file(path): doc = None if os.path.exists(path):