streamed_package_provider - ryzom/ryzomcore GitHub Wiki
title: Streamed Package Provider description: Download and cache LZMA-compressed game assets from an HTTP CDN published: true date: 2026-03-16T00:00:00.000Z tags: editor: markdown dateCreated: 2026-03-16T00:00:00.000Z
CHttpPackageProvider implements the IStreamedPackageProvider interface to download game assets on demand from an HTTP CDN. Files are downloaded as LZMA-compressed archives, decompressed, verified by SHA1 hash, and cached locally for subsequent access.
This is the mechanism used by the Ryzom client to stream assets that are not included in the initial install, avoiding large upfront downloads.
Header: nel/web/http_package_provider.h
#include <nel/web/http_package_provider.h>
#include <nel/misc/streamed_package_manager.h>
// Create and configure the provider
NLWEB::CHttpPackageProvider *provider = new NLWEB::CHttpPackageProvider();
provider->Path = "stream/"; // local cache directory
provider->Hosts.push_back("http://cdn.example.com/assets/stream/");
// Register with the streamed package manager
NLMISC::CStreamedPackageManager &spm = NLMISC::CStreamedPackageManager::getInstance();
spm.Provider = provider;
// Assets are now downloaded on demand when CPath resolves a streamed file| Member | Type | Description |
|---|---|---|
Path |
std::string |
Local directory for caching downloaded files. Files are stored in a hash-based subdirectory tree. |
Hosts |
std::vector<std::string> |
List of HTTP CDN base URLs to download from. The provider tries each host in order. |
When getFile is called with a SHA1 hash:
-
Check local cache — If the file already exists at
Path + hash_path, return it immediately. -
Download — Fetch
host + hash_path + ".lzma"from each configured CDN host until one succeeds. The download goes to a temporary.download.RANDOMfile. -
Decompress — LZMA-decompress the downloaded file to a temporary
.extract.RANDOMfile. - Verify — Compute the SHA1 hash of the decompressed file and compare against the expected hash.
- Store — Move the verified file to its final cache location.
- Return — Return the local file path for NeL to load.
If the download fails, the provider retries with a 1-second delay between attempts. The operation is blocking — it runs on the async file loading thread, not the main thread.
File paths within the cache use the format from CStreamedPackage::makePath(hash), which creates a directory tree based on the hash bytes to avoid having too many files in a single directory.
- Download failure: Retries indefinitely with 1-second delays, cycling through configured hosts.
- Hash mismatch: The corrupted file is deleted and the download is retried.
-
Disk full: Throws
NLMISC::EDiskFullError. - Race condition: If two threads try to download the same file simultaneously, the second thread detects the file has appeared and returns it without re-downloading.
The Ryzom client configures the provider from client.cfg:
StreamedPackagePath = "stream/";
StreamedPackageHosts = {
"http://cdn.ryzom.dev/open/stream/"
};
The provider is created during client initialization (initStreamedPackageManager in init.cpp) and destroyed during shutdown (release.cpp).
- HTTP Client — The underlying HTTP client used for downloads
- Creating and Using Big Files — Alternative local packaging system