fix: Remove meta-bundle caching (#33029)

- This has never worked
- using `modified` isn't a good way to invalidate this cache because it
  doesn't change with customization
This commit is contained in:
Ankush Menat 2025-06-20 18:33:30 +05:30 committed by GitHub
parent 18ecd6603b
commit f56c405e26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 48 deletions

View file

@ -59,7 +59,7 @@ def getdoc(doctype, name):
@frappe.whitelist()
def getdoctype(doctype, with_parent=False, cached_timestamp=None):
def getdoctype(doctype, with_parent=False):
"""load doctype"""
docs = []
@ -75,9 +75,6 @@ def getdoctype(doctype, with_parent=False, cached_timestamp=None):
frappe.response["user_settings"] = get_user_settings(parent_dt or doctype)
if cached_timestamp and docs[0].modified == cached_timestamp:
return "use_cache"
frappe.response.docs.extend(docs)

View file

@ -212,55 +212,17 @@ $.extend(frappe.model, {
return docfield[0];
},
get_from_localstorage: function (doctype) {
if (localStorage["_doctype:" + doctype]) {
return JSON.parse(localStorage["_doctype:" + doctype]);
}
},
set_in_localstorage: function (doctype, docs) {
try {
localStorage["_doctype:" + doctype] = JSON.stringify(docs);
} catch (e) {
// if quota is exceeded, clear local storage and set item
console.warn("localStorage quota exceeded, clearing doctype cache");
frappe.model.clear_local_storage();
localStorage["_doctype:" + doctype] = JSON.stringify(docs);
}
},
clear_local_storage: function () {
for (var key in localStorage) {
if (key.startsWith("_doctype:")) {
localStorage.removeItem(key);
}
}
},
with_doctype: function (doctype, callback, async) {
if (locals.DocType[doctype]) {
callback && callback();
return Promise.resolve();
} else {
let cached_timestamp = null;
let meta = null;
let cached_docs = frappe.model.get_from_localstorage(doctype);
if (cached_docs) {
meta = cached_docs.filter((doc) => doc.name === doctype)[0];
if (meta) {
cached_timestamp = meta.modified;
}
}
return frappe.call({
method: "frappe.desk.form.load.getdoctype",
type: "GET",
args: {
doctype: doctype,
with_parent: 1,
cached_timestamp: cached_timestamp,
},
async: async,
callback: function (r) {
@ -268,12 +230,7 @@ $.extend(frappe.model, {
frappe.msgprint(__("Unable to load: {0}", [__(doctype)]));
throw "No doctype";
}
if (r.message == "use_cache") {
frappe.model.sync(meta);
} else {
frappe.model.set_in_localstorage(doctype, r.docs);
meta = r.docs[0];
}
let meta = r.docs[0];
frappe.model.init_doctype(meta);
if (r.user_settings) {