Commit: b3be710e1933f3a2fb01ab67dfd8f05ffbb77a21
Author: Bastien Montagne
Date:   Wed Apr 27 13:13:00 2016 +0200
Branches: asset-engine
https://developer.blender.org/rBb3be710e1933f3a2fb01ab67dfd8f05ffbb77a21

Some tweaks to flags & versionning handling for assets update check.

===================================================================

M       release/scripts/startup/bl_operators/amber.py
M       source/blender/windowmanager/intern/wm_files_link.c

===================================================================

diff --git a/release/scripts/startup/bl_operators/amber.py 
b/release/scripts/startup/bl_operators/amber.py
index 2cb7c6d..7db2972 100644
--- a/release/scripts/startup/bl_operators/amber.py
+++ b/release/scripts/startup/bl_operators/amber.py
@@ -253,7 +253,7 @@ class AmberTag(PropertyGroup):
 
 class AssetEngineAmber(AssetEngine):
     bl_label = "Amber"
-    bl_version = 1
+    bl_version = (0 << 16) + (0 << 8) + 2  # Usual maj.min.rev version 
scheme...
 
     tags = CollectionProperty(name="Tags", type=AmberTag, 
description="Filtering tags")
     active_tag_index = IntProperty(name="Active Tag", options={'HIDDEN'})
@@ -341,6 +341,11 @@ class AssetEngineAmber(AssetEngine):
             entry.relpath = act_rev["path"]
 #        print("added entry for", entry.relpath)
 
+    def pretty_version(self, v=None):
+        if v is None:
+            v = self.bl_version
+        return "%d.%d.%d" % ((v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF)
+
     ########## PY-API only ##########
     # UI header
     def draw_header(self, layout, context):
@@ -443,12 +448,20 @@ class AssetEngineAmber(AssetEngine):
 
     def update_check(self, job_id, uuids):
         # do nothing for now, no need to use actual job...
+        if uuids.asset_engine_version != self.bl_version:
+            print("Updating asset uuids from Amber v.%s to amber v.%s" %
+                  (self.pretty_version(uuids.asset_engine_version), 
self.pretty_version()))
+        # We could also check for uuid.is_asset_missing (in case our .blend 
lib files would be cached locally and
+        # gone missing e.g.).
         for uuid in uuids.uuids:
             uuid.use_asset_reload = True
         return self.job_id_invalid
 
     def load_pre(self, uuids, entries):
         # Not quite sure this engine will need it in the end, but for sake of 
testing...
+        if uuids.asset_engine_version != self.bl_version:
+            print("Updating asset uuids from Amber v.%s to amber v.%s" %
+                  (self.pretty_version(uuids.asset_engine_version), 
self.pretty_version()))
         if self.repo:
 #            print(entries.entries[:])
             for uuid in uuids.uuids:
diff --git a/source/blender/windowmanager/intern/wm_files_link.c 
b/source/blender/windowmanager/intern/wm_files_link.c
index 86f63e1..174bc3b 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -588,6 +588,8 @@ static void asset_updatecheck_update(void *aucjv)
 
        *aucj->progress = 0.0f;
 
+       /* TODO need to take care of 'broken' engines that error - in this case 
we probably want to cancel the whole
+        * update process over effected libraries' data... */
        for (AssetUpdateCheckEngine *auce = aucj->engines.first; auce; auce = 
auce->next, nbr_engines++) {
                AssetEngine *ae = auce->ae;
                AssetEngineType *ae_type = ae->type;
@@ -618,6 +620,10 @@ static void asset_updatecheck_update(void *aucjv)
                                                continue;
                                        }
 
+                                       /* UUIDs returned by update_check are 
assumed to be valid (one way or the other) in current
+                                        * asset engine version. */
+                                       
lib->asset_repository->asset_engine_version = ae_type->version;
+
                                        int i = auce->uuids.nbr_uuids;
                                        for (AssetUUID *uuid = 
auce->uuids.uuids; i--; uuid++) {
                                                bool done = false;
@@ -754,7 +760,7 @@ static void asset_updatecheck_start(const bContext *C)
 
                                        if (id->uuid) {
                                                printf("\tWe need to check for 
updated asset %s...\n", id->name);
-                                               id->uuid->tag = 0;
+                                               id->uuid->tag = (id->tag & 
LIB_TAG_MISSING) ? UUID_TAG_ASSET_MISSING : 0;
 
                                                /* XXX horrible, need to use 
some mempool, stack or something :) */
                                                auce->uuids.nbr_uuids++;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to