Blender V5.3
blender::asset_system Namespace Reference

Namespaces

namespace  tests
namespace  utils

Classes

class  AllAssetLibrary
class  AssetCatalog
class  AssetCatalogCollection
class  AssetCatalogDefinitionFile
class  AssetCatalogFilter
struct  AssetCatalogLessThan
class  AssetCatalogPath
class  AssetCatalogService
class  AssetCatalogTree
class  AssetCatalogTreeItem
class  AssetLibrary
class  AssetLibraryService
class  AssetRepresentation
class  DiskFileHashService
class  EssentialsAssetLibrary
struct  FileProgress
class  OnDiskAssetLibrary
struct  OnlineAssetFile
struct  OnlineAssetInfo
class  OnlineEssentialsLibrary
class  PreferencesOnDiskAssetLibrary
class  PreferencesRemoteAssetLibrary
struct  ProgressData
struct  ProgressTracker
class  RemoteAssetLibrary
struct  RemoteLibraryDefinitionRef
class  RemoteLibraryLoadingStatus
struct  RequestIdentifier
class  RuntimeAssetLibrary
struct  URLWithHash
class  UserAssetLibraryWrapper

Typedefs

using CatalogID = UUID
using CatalogPathComponent = std::string
using CatalogFilePath = std::string
using OwningAssetCatalogMap = Map<CatalogID, std::unique_ptr<AssetCatalog>>
using AssetCatalogOrderedSet = std::set<const AssetCatalog *, AssetCatalogLessThan>
using MutableAssetCatalogOrderedSet = std::set<AssetCatalog *, AssetCatalogLessThan>

Enumerations

enum class  RemoteAssetFileStatus { UNSET = 0 , NOT_ON_DISK = 1 , MATCH = 2 , NO_MATCH = 3 }

Functions

std::ostream & operator<< (std::ostream &stream, const AssetCatalogPath &path_to_append)
Vector< AssetLibraryReference > all_valid_asset_library_refs ()
AssetLibraryReference all_library_reference ()
AssetLibraryReference essentials_library_reference ()
AssetLibraryReference current_file_library_reference ()
AssetLibraryReference online_essentials_library_reference ()
void all_library_tag_catalogs_dirty ()
void all_library_reload_catalogs_if_dirty ()
bool is_or_contains_remote_libraries (const AssetLibraryReference &reference)
bool contains_assets_from_remote_url (const AssetLibrary &library, StringRef remote_url)
std::unique_ptr< DiskFileHashService > disk_file_hash_service_get (StringRef storage_path)
StringRefNull essentials_directory_path ()
bool skip_experimental_asset_catalog (const UUID &catalog_id)
static std::string asset_definition_default_file_path_from_dir (StringRef asset_library_root)
static void copy_catalog_map_into_existing (const OwningAssetCatalogMap &source, OwningAssetCatalogMap &dest, AssetCatalogCollection::OnDuplicateCatalogIdFn on_duplicate_items)
static void on_blendfile_load (Main *, PointerRNA **, const int, void *)
Online Essentials Library

Internally this is a separate library. To the user, it's part of the normal Essentials library.

StringRefNull online_essentials_cache_directory_path ()
StringRefNull online_essentials_url ()
bool is_online_essentials_url (StringRef url)
bool is_online_essentials_dirpath (StringRef dirpath)
Other Free Functions
std::string remote_library_top_meta_file_path (const RemoteLibraryDefinitionRef &library)
bool remote_library_url_ends_with_top_meta_file_name (const StringRef url)
void foreach_registered_user_remote_library (FunctionRef< void(bUserAssetLibrary &)> fn)
Download Requests
void remote_library_request_download (const RemoteLibraryDefinitionRef &library_definition)
void remote_library_cancel_all_listing_downloads (const bContext &C)
void remote_library_request_asset_download (const bContext &C, const AssetRepresentation &asset, ReportList *reports)
void remote_library_request_preview_download (const bContext &C, const AssetRepresentation &asset, const StringRef dst_filepath, ReportList *reports)
Download Cancelling
void remote_library_cancel_all_asset_downloads (bContext &C)

Variables

constexpr StringRefNull REMOTE_LIBRARY_TOP_META_FILE_NAME = "_asset-library-meta.json"
constexpr StringRefNull REMOTE_LIBRARY_TOP_META_FILE_NAME_LEADING_SLASH
static CLG_LogRef LOG = {"asset.library.essentials"}

Progress Tracking

enum class  DownloadOutcome { Succeeded , Failed }
float remote_library_total_asset_downloads_progress ()
bool remote_library_has_unfinished_asset_downloads ()

Remote Library Loading Status

using UrlToLibraryStatusMap = Map<std::string , asset_system::RemoteLibraryLoadingStatus>
static UrlToLibraryStatusMap & library_to_status_map ()
static void ping_asset_file_done_impl (const bContext &C, const StringRef library_url, const StringRef absolute_file_url, const StringRef local_file_abspath, const DownloadOutcome outcome)

Cache Paths

const int8_t REMOTE_LIBRARY_DIRNAME_LEN = 16
std::string remote_library_cache_directory_path (StringRefNull library_dirname)
std::string remote_library_cache_directory_path_from_url (StringRef remote_url)
std::string remote_library_asset_preview_path (const AssetRepresentation &asset)

Typedef Documentation

◆ AssetCatalogOrderedSet

Set that stores catalogs ordered by (path, UUID). Being a set, duplicates are removed. The catalog's simple name is ignored in this.

Definition at line 385 of file AS_asset_catalog.hh.

◆ CatalogFilePath

Definition at line 36 of file AS_asset_catalog.hh.

◆ CatalogID

Definition at line 32 of file AS_asset_catalog.hh.

◆ CatalogPathComponent

Definition at line 33 of file AS_asset_catalog.hh.

◆ MutableAssetCatalogOrderedSet

◆ OwningAssetCatalogMap

Definition at line 37 of file AS_asset_catalog.hh.

◆ UrlToLibraryStatusMap

Enumeration Type Documentation

◆ DownloadOutcome

Enumerator
Succeeded 
Failed 

Definition at line 268 of file remote_library.cc.

◆ RemoteAssetFileStatus

Status of the asset's file(s) on disk, compared to the remote asset listing.

Enumerator
UNSET 

Just so you can recognize a zero-initialized field of this type.

NOT_ON_DISK 

The asset's main file does not exist on disk.

MATCH 

All the asset's files exist on disk, and match the listing's hashes.

NO_MATCH 

At least one of the asset's files exists on disk, but doesn't match the listing's hash.

Definition at line 16 of file AS_asset_file_status.hh.

Function Documentation

◆ all_library_reference()

◆ all_library_reload_catalogs_if_dirty()

◆ all_library_tag_catalogs_dirty()

◆ all_valid_asset_library_refs()

◆ asset_definition_default_file_path_from_dir()

◆ contains_assets_from_remote_url()

◆ copy_catalog_map_into_existing()

◆ current_file_library_reference()

◆ disk_file_hash_service_get()

std::unique_ptr< DiskFileHashService > blender::asset_system::disk_file_hash_service_get ( StringRef storage_path)

Obtain a DiskFileHashService, which stores its cache at the given location.

Definition at line 25 of file disk_file_hash_service.cc.

References disk_file_hash_service_get().

Referenced by disk_file_hash_service_get(), and blender::ed::asset::index::FileStatusChecker::FileStatusChecker().

◆ essentials_directory_path()

◆ essentials_library_reference()

◆ foreach_registered_user_remote_library()

void blender::asset_system::foreach_registered_user_remote_library ( FunctionRef< void(bUserAssetLibrary &)> fn)

Iterates all libraries registered in the Preferences and calls the given function with the URL of the library.

Note
Does not include the online essentials library.

Definition at line 1115 of file remote_library.cc.

References blender::ASSET_LIBRARY_USE_REMOTE_URL, foreach_registered_user_remote_library(), and blender::U.

Referenced by blender::filelist_start_job_all_asset_library(), and foreach_registered_user_remote_library().

◆ is_online_essentials_dirpath()

bool blender::asset_system::is_online_essentials_dirpath ( StringRef dirpath)

Check if the given absolute directory path is the online essentials cache path. If the path ends in a trailing slash, that's stripped before comparing.

Definition at line 174 of file essentials_library.cc.

References blender::BLI_assert(), blender::StringRef::drop_known_suffix(), blender::blender::StringRefBase::endswith(), blender::blender::StringRefBase::is_empty(), is_online_essentials_dirpath(), online_essentials_cache_directory_path(), and SEP_STR.

Referenced by is_online_essentials_dirpath(), and remote_library_request_download().

◆ is_online_essentials_url()

◆ is_or_contains_remote_libraries()

◆ library_to_status_map()

◆ on_blendfile_load()

void blender::asset_system::on_blendfile_load ( Main * ,
PointerRNA ** ,
const int ,
void *  )
static

◆ online_essentials_cache_directory_path()

◆ online_essentials_library_reference()

◆ online_essentials_url()

◆ operator<<()

◆ ping_asset_file_done_impl()

◆ remote_library_asset_preview_path()

std::string blender::asset_system::remote_library_asset_preview_path ( const AssetRepresentation & asset)

Get the absolute file path the preview for asset is expected at once downloaded.

The path is built like this:

  • Online library cache directory (e.g. $HOME/.cache/blender/remote-assets/1a2b3c-my.assets.com/)
  • _thumbs/large/
  • The first two characters of the MD5 hash of the full asset path (#AssetRepresentation.full_path()).
  • The next 30 characters of the MD5 hash.
  • If the download URL of the preview has an extension (some string after a period), up to 6 characters of that extension. (Previews load fine regardless of the extension. But the extension is still a useful indicator, and some file browsers can display previews that way.)

The reason hashes are used within _thumbs/large/ instead of the relative path of the asset (or another relative path derived from the preview URL) is to keep paths short enough to not violate path length limitations.

Definition at line 1048 of file remote_library.cc.

References BLI_assert_unreachable, blender::BLI_hash_md5_buffer(), blender::BLI_hash_md5_to_hexdigest(), blender::BLI_path_extension_or_end(), BLI_path_join, blender::StringRefNull::c_str(), FILE_MAX, FILE_MAXDIR, blender::asset_system::AssetRepresentation::full_path(), blender::asset_system::AssetRepresentation::online_asset_preview_url(), blender::asset_system::AssetRepresentation::owner_asset_library(), remote_library_asset_preview_path(), blender::asset_system::AssetLibrary::root_path(), and SNPRINTF.

Referenced by blender::asset_system::AssetRepresentation::ensure_previewable(), and remote_library_asset_preview_path().

◆ remote_library_cache_directory_path()

std::string blender::asset_system::remote_library_cache_directory_path ( StringRefNull library_dirname)

Get the absolute path to an online library's cache directory using library_dirname as library identifier.

The path is the general cache directory (e.g. $HOME/.cache/blender/remote-assets/) plus the library_dirname as subdirectory.

The resulting path will be shortened to FILE_MAXDIR if necessary.

Definition at line 1033 of file remote_library.cc.

References blender::BKE_appdir_folder_caches(), BLI_path_join, blender::StringRefNull::c_str(), FILE_MAXDIR, and remote_library_cache_directory_path().

Referenced by online_essentials_cache_directory_path(), remote_library_cache_directory_path(), and remote_library_cache_directory_path_from_url().

◆ remote_library_cache_directory_path_from_url()

std::string blender::asset_system::remote_library_cache_directory_path_from_url ( StringRef remote_url)

Determine the absolute path of the asset library's on-disk cache directory for downloaded files, based on the library's URL.

The path is the general cache directory (e.g. $HOME/.cache/blender/remote-assets/) plus a shortened MD5 hash of the remote URL to identify the library.

This is based on the remote URL of the library, and not the library name, as the name can be user-chosen, so the URL is a more stable identifier. And if there happen to be multiple libraries in the preferences, with the same URL, they'll share the same cache.

The resulting path will be shortened to FILE_MAXDIR if necessary.

Definition at line 1013 of file remote_library.cc.

References BLI_assert_msg, blender::BLI_hash_md5_buffer(), blender::BLI_hash_md5_to_hexdigest(), blender::BLI_strncpy(), blender::blender::StringRefBase::data(), online_essentials_url(), remote_library_cache_directory_path(), remote_library_cache_directory_path_from_url(), REMOTE_LIBRARY_DIRNAME_LEN, and blender::blender::StringRefBase::size().

Referenced by blender::BKE_preferences_remote_asset_library_url_set(), and remote_library_cache_directory_path_from_url().

◆ remote_library_cancel_all_asset_downloads()

◆ remote_library_cancel_all_listing_downloads()

◆ remote_library_has_unfinished_asset_downloads()

bool blender::asset_system::remote_library_has_unfinished_asset_downloads ( )

Return true if there is any asset file (any file in an assets file set) being downloaded.

Definition at line 390 of file remote_library.cc.

References blender::asset_system::ProgressTracker::is_any_loading(), and remote_library_has_unfinished_asset_downloads().

Referenced by remote_library_has_unfinished_asset_downloads(), and blender::ui::template_running_jobs().

◆ remote_library_request_asset_download()

◆ remote_library_request_download()

◆ remote_library_request_preview_download()

◆ remote_library_top_meta_file_path()

std::string blender::asset_system::remote_library_top_meta_file_path ( const RemoteLibraryDefinitionRef & library)

Get the absolute file path to the _asset-library-meta.json of the given library's cache directory.

Definition at line 1097 of file remote_library.cc.

References BLI_path_join, FILE_MAX, REMOTE_LIBRARY_TOP_META_FILE_NAME, and remote_library_top_meta_file_path().

Referenced by blender::remote_asset_library_request(), and remote_library_top_meta_file_path().

◆ remote_library_total_asset_downloads_progress()

◆ remote_library_url_ends_with_top_meta_file_name()

◆ skip_experimental_asset_catalog()

bool blender::asset_system::skip_experimental_asset_catalog ( const UUID & catalog_id)

Variable Documentation

◆ LOG

CLG_LogRef blender::asset_system::LOG = {"asset.library.essentials"}
static

Definition at line 30 of file essentials_library.cc.

◆ REMOTE_LIBRARY_DIRNAME_LEN

const int8_t blender::asset_system::REMOTE_LIBRARY_DIRNAME_LEN = 16

Maximum length of the remote library directory name. Kept short to avoid path length issues with deeply nested asset libraries.

The directory name will be the MD5 hash of the URL.

Definition at line 1011 of file remote_library.cc.

Referenced by remote_library_cache_directory_path_from_url().

◆ REMOTE_LIBRARY_TOP_META_FILE_NAME

StringRefNull blender::asset_system::REMOTE_LIBRARY_TOP_META_FILE_NAME = "_asset-library-meta.json"
constexpr

◆ REMOTE_LIBRARY_TOP_META_FILE_NAME_LEADING_SLASH

StringRefNull blender::asset_system::REMOTE_LIBRARY_TOP_META_FILE_NAME_LEADING_SLASH
constexpr
Initial value:
=
"/_asset-library-meta.json"

Definition at line 44 of file AS_remote_library.hh.

Referenced by remote_library_url_ends_with_top_meta_file_name().