History

Merge pull request #664 from kasenvr/feature/require-redownload

Feature/require redownload

kasenvr committed 5 years ago

Commit 50809092 parents 8f4f15b 05ad3006 files · +30 −5Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 6 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+4−1
@@ -1941,9 +1941,12 @@ QScriptValue ScriptEngine::require(const QString& moduleId) { · 1940 unmodified lines
19411941 // modules get cached in `Script.require.cache` and (similar to Node.js) users can access it
19421942 // to inspect particular entries and invalidate them by deleting the key:
19431943 // `delete Script.require.cache[Script.require.resolve(moduleId)];`
1944+
1945+ // Check to see if we should invalidate the cache based on a user setting.
1946+ Setting::Handle<bool> getCachebustSetting {"cachebustScriptRequire", false };
19441947
19451948 // cacheMeta is just used right now to tell deleted keys apart from undefined ones
1946− bool invalidateCache = module.isUndefined() && cacheMeta.property(moduleId).isValid();
1949+ bool invalidateCache = getCachebustSetting.get() || (module.isUndefined() && cacheMeta.property(moduleId).isValid());
19471950
19481951 // reset the cacheMeta record so invalidation won't apply next time, even if the module fails to load
19491952 cacheMeta.setProperty(modulePath, QScriptValue());