diff --git a/include/openspace/util/resourcesynchronization.h b/include/openspace/util/resourcesynchronization.h index ce65a4ff7b..50a0f46fad 100644 --- a/include/openspace/util/resourcesynchronization.h +++ b/include/openspace/util/resourcesynchronization.h @@ -70,18 +70,9 @@ public: const ghoul::Dictionary& dictionary); /** - * Generates a unique identifying string for the dictionary that is based on the - * \c Type and the \c Identifier values of the passed \p dictionary. All other - * parameters are ignored, but as long as the \c Type and/or the \c Identifier values - * differ, the resulting string will be different. - * - * \param dictionary The dictionary containing the \c Type and the \c Identifier used - * to create a unique identifier - * - * \throw SpecificationError If the \p dictionary does not contain a \c Type, an - * \c Identifier, and a \c Name + * Generates a unique identifying string for ResourceSynchronizaiton. */ - static std::string generateUid(const ghoul::Dictionary& dictionary); + virtual std::string generateUid() = 0; /// Defaulted virtual constructor virtual ~ResourceSynchronization() = default; diff --git a/modules/sync/syncs/httpsynchronization.cpp b/modules/sync/syncs/httpsynchronization.cpp index be69996846..41f73bd113 100644 --- a/modules/sync/syncs/httpsynchronization.cpp +++ b/modules/sync/syncs/httpsynchronization.cpp @@ -117,6 +117,10 @@ void HttpSynchronization::cancel() { _state = State::Unsynced; } +std::string HttpSynchronization::generateUid() { + return fmt::format("{}/{}", _identifier, _version); +} + bool HttpSynchronization::trySyncFromUrl(std::string listUrl) { HttpMemoryDownload fileListDownload(std::move(listUrl)); fileListDownload.onProgress([&c = _shouldCancel](int64_t, std::optional) { diff --git a/modules/sync/syncs/httpsynchronization.h b/modules/sync/syncs/httpsynchronization.h index 034f261210..68c039201a 100644 --- a/modules/sync/syncs/httpsynchronization.h +++ b/modules/sync/syncs/httpsynchronization.h @@ -87,6 +87,8 @@ public: /// Cancels any ongoing synchronization of this ResourceSynchronization void cancel() override; + std::string generateUid() override; + static documentation::Documentation Documentation(); private: diff --git a/modules/sync/syncs/urlsynchronization.cpp b/modules/sync/syncs/urlsynchronization.cpp index c611589d65..68f5b091b3 100644 --- a/modules/sync/syncs/urlsynchronization.cpp +++ b/modules/sync/syncs/urlsynchronization.cpp @@ -245,4 +245,8 @@ void UrlSynchronization::cancel() { _state = State::Unsynced; } +std::string UrlSynchronization::generateUid() { + return _identifier; +} + } // namespace openspace diff --git a/modules/sync/syncs/urlsynchronization.h b/modules/sync/syncs/urlsynchronization.h index e8684d2aca..8747d7cf82 100644 --- a/modules/sync/syncs/urlsynchronization.h +++ b/modules/sync/syncs/urlsynchronization.h @@ -73,6 +73,8 @@ public: /// Cancels any ongoing synchronization of this ResourceSynchronization void cancel() override; + std::string generateUid() override; + static documentation::Documentation Documentation(); private: diff --git a/src/scene/assetmanager.cpp b/src/scene/assetmanager.cpp index 73a2623b0e..d491cd98a6 100644 --- a/src/scene/assetmanager.cpp +++ b/src/scene/assetmanager.cpp @@ -495,14 +495,13 @@ void AssetManager::setUpAssetLuaTable(Asset* asset) { Asset* thisAsset = ghoul::lua::userData(L, 2); ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::syncedResourceLua"); ghoul::Dictionary d = ghoul::lua::value(L); - - std::string uid = ResourceSynchronization::generateUid(d); + std::unique_ptr s = + ResourceSynchronization::createFromDictionary(d); + + std::string uid = d.value("Type") + "/" + s->generateUid(); SyncItem* syncItem = nullptr; auto it = manager->_synchronizations.find(uid); if (it == manager->_synchronizations.end()) { - std::unique_ptr s = - ResourceSynchronization::createFromDictionary(d); - auto si = std::make_unique(); si->synchronization = std::move(s); si->assets.push_back(thisAsset); diff --git a/src/util/resourcesynchronization.cpp b/src/util/resourcesynchronization.cpp index ca5b148dcd..c8f1b868b5 100644 --- a/src/util/resourcesynchronization.cpp +++ b/src/util/resourcesynchronization.cpp @@ -68,11 +68,6 @@ std::unique_ptr ResourceSynchronization::createFromDict return std::unique_ptr(sync); } -std::string ResourceSynchronization::generateUid(const ghoul::Dictionary& dictionary) { - const Parameters p = codegen::bake(dictionary); - return fmt::format("{}/{}", p.type, p.identifier); -} - ResourceSynchronization::ResourceSynchronization( std::filesystem::path synchronizationRoot) : _synchronizationRoot(std::move(synchronizationRoot))