Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2021-09-27 16:28:16 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-09-27 19:14:21 +0300
commit10061ee18ae97968bc9e0a7d83a353b077329aca (patch)
tree322d58f7c54bed5a3b642937fff0c0dc793864e0 /source/blender/blenkernel/BKE_asset_catalog.hh
parent90aa0a52568c629e466b6ccc513afadd0144ee1e (diff)
Asset Catalogs: write catalogs to disk when saving the blend file
The Asset Catalog Definition File is now saved whenever the blend file is saved. The location of the CDF depends on where the blend file is saved, and whether previously a CDF was already loaded, according to the following rules. The first matching rule wins: 1. Already loaded a CDF from disk? -> Always write to that file. 2. The directory containing the blend file has a `blender_assets.cats.txt` file? -> Merge with & write to that file. 3. The directory containing the blend file is part of an asset library, as per the user's preferences? -> Merge with & write to `${ASSET_LIBRARY_ROOT}/blender_assets.cats.txt` 4. Create a new file `blender_assets.cats.txt` next to the blend file.
Diffstat (limited to 'source/blender/blenkernel/BKE_asset_catalog.hh')
-rw-r--r--source/blender/blenkernel/BKE_asset_catalog.hh28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_asset_catalog.hh b/source/blender/blenkernel/BKE_asset_catalog.hh
index 07373caf701..7b54d7cf572 100644
--- a/source/blender/blenkernel/BKE_asset_catalog.hh
+++ b/source/blender/blenkernel/BKE_asset_catalog.hh
@@ -74,6 +74,25 @@ class AssetCatalogService {
bool write_to_disk(const CatalogFilePath &directory_for_new_files);
/**
+ * Write the catalog definitions to disk in response to the blend file being saved.
+ *
+ * The location where the catalogs are saved is variable, and depends on the location of the
+ * blend file. The first matching rule wins:
+ *
+ * - Already loaded a CDF from disk?
+ * -> Always write to that file.
+ * - The directory containing the blend file has a blender_assets.cats.txt file?
+ * -> Merge with & write to that file.
+ * - The directory containing the blend file is part of an asset library, as per
+ * the user's preferences?
+ * -> Merge with & write to ${ASSET_LIBRARY_ROOT}/blender_assets.cats.txt
+ * - Create a new file blender_assets.cats.txt next to the blend file.
+ *
+ * Return true on success, which either means there were no in-memory categories to save,
+ * or the save was successful. */
+ bool write_to_disk_on_blendfile_save(const char *blend_file_path);
+
+ /**
* Merge on-disk changes into the in-memory asset catalogs.
* This should be called before writing the asset catalogs to disk.
*
@@ -124,6 +143,15 @@ class AssetCatalogService {
std::unique_ptr<AssetCatalogDefinitionFile> construct_cdf_in_memory(
const CatalogFilePath &file_path);
+ /**
+ * Find a suitable path to write a CDF to.
+ *
+ * This depends on the location of the blend file, and on whether a CDF already exists next to it
+ * or whether the blend file is saved inside an asset library.
+ */
+ static CatalogFilePath find_suitable_cdf_path_for_writing(
+ const CatalogFilePath &blend_file_path);
+
std::unique_ptr<AssetCatalogTree> read_into_tree();
void rebuild_tree();
};