History

Add forceRedownload parameter to Script.require

Kalila L committed 6 years ago

Commit 26455471 parent 3d8128c2 files · +6 −3Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+3−2
@@ -4,6 +4,7 @@ · 3 unmodified lines
44 //
55 // Created by Brad Hefta-Gaub on 12/14/13.
66 // Copyright 2013 High Fidelity, Inc.
7+// Copyright 2020 Vircadia contributors.
78 //
89 // Distributed under the Apache License, Version 2.0.
910 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@@ -1836,7 +1837,7 @@ QScriptValue ScriptEngine::instantiateModule(const QScriptValue& module, const Q · 1826 unmodified lines
18361837 }
18371838
18381839 // CommonJS/Node.js like require/module support
1839−QScriptValue ScriptEngine::require(const QString& moduleId) {
1840+QScriptValue ScriptEngine::require(const QString& moduleId, bool forceRedownload) {
18401841 qCDebug(scriptengine_module) << "ScriptEngine::require(" << moduleId.left(MAX_DEBUG_VALUE_LENGTH) << ")";
18411842 if (!IS_THREADSAFE_INVOCATION(thread(), __FUNCTION__)) {
18421843 return unboundNullValue();
@@ -1875,7 +1876,7 @@ QScriptValue ScriptEngine::require(const QString& moduleId) { · 32 unmodified lines
18751876 // `delete Script.require.cache[Script.require.resolve(moduleId)];`
18761877
18771878 // cacheMeta is just used right now to tell deleted keys apart from undefined ones
1878− bool invalidateCache = module.isUndefined() && cacheMeta.property(moduleId).isValid();
1879+ bool invalidateCache = (module.isUndefined() && cacheMeta.property(moduleId).isValid()) || forceRedownload;
18791880
18801881 // reset the cacheMeta record so invalidation won't apply next time, even if the module fails to load
18811882 cacheMeta.setProperty(modulePath, QScriptValue());