Feature/require redownload
Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 6 files). Show all
Unified · Split
| @@ -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 it | 1941 | // 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 ones | 1948 | // 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 load | 1951 | // 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()); |