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
1941 // modules get cached in `Script.require.cache` and (similar to Node.js) users can access it1941 // modules get cached in `Script.require.cache` and (similar to Node.js) users can access it
1942 // to inspect particular entries and invalidate them by deleting the key:1942 // to inspect particular entries and invalidate them by deleting the key:
1943 // `delete Script.require.cache[Script.require.resolve(moduleId)];`1943 // `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 };
1944 1947
1945 // cacheMeta is just used right now to tell deleted keys apart from undefined ones1948 // 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());
1947 1950
1948 // reset the cacheMeta record so invalidation won't apply next time, even if the module fails to load1951 // reset the cacheMeta record so invalidation won't apply next time, even if the module fails to load
1949 cacheMeta.setProperty(modulePath, QScriptValue());1952 cacheMeta.setProperty(modulePath, QScriptValue());