Skip to content

Commit

Permalink
Enhancement: Workfile out of date handling using UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharkitty committed Mar 12, 2024
1 parent 1a5617f commit 9113a28
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
7 changes: 6 additions & 1 deletion openpype/hosts/blender/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import contextlib
from pathlib import Path
from typing import Dict, List, Union
from datetime import datetime

import bpy
import addon_utils
from openpype.lib import Logger
from openpype.lib.dateutils import get_timestamp
from openpype.modules import ModulesManager
from openpype.pipeline import Anatomy
from openpype.pipeline.template_data import (
Expand Down Expand Up @@ -456,7 +458,10 @@ def download_last_workfile(
):
raise OSError("Failed to download last published workfile")

return last_published_workfile_path, last_version_doc["data"]["time"]
return (
last_published_workfile_path,
get_timestamp(datetime_obj=datetime.utcnow()),
)


def save_as_local_workfile(
Expand Down
5 changes: 4 additions & 1 deletion openpype/hosts/blender/api/workio.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ def check_workfile_up_to_date() -> bool:

scene = bpy.context.scene

last_published_time = last_published_version["data"]["time"]
last_published_time = (
last_published_version["data"].get("utc_time")
or last_published_version["data"]["time"]
)
if scene.get("op_published_time"):
return last_published_time <= scene["op_published_time"]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ class UpdateCurrentWorkfileLastPublishTime(pyblish.api.ContextPlugin):

def process(self, context):
scene = bpy.context.scene
scene["op_published_time"] = context.data["time"]
scene["op_published_time"] = context.data["utc_time"]
scene.is_workfile_up_to_date = True
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import bpy
from datetime import datetime

from openpype.lib.log import Logger
from openpype.lib.dateutils import get_timestamp
Expand Down
8 changes: 7 additions & 1 deletion openpype/plugins/publish/collect_time.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from datetime import datetime

import pyblish.api
from openpype.lib import get_formatted_current_time

from openpype.lib import get_formatted_current_time, get_timestamp


class CollectTime(pyblish.api.ContextPlugin):
Expand All @@ -10,3 +13,6 @@ class CollectTime(pyblish.api.ContextPlugin):

def process(self, context):
context.data["time"] = get_formatted_current_time()
context.data["utc_time"] = get_timestamp(
datetime_obj=datetime.utcnow()
)
1 change: 1 addition & 0 deletions openpype/plugins/publish/integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ def create_version_data(self, instance):
version_data = {
"families": get_instance_families(instance),
"time": context.data["time"],
"utc_time": context.data["utc_time"],
"author": context.data["user"],
"source": source,
"comment": instance.data["comment"],
Expand Down

0 comments on commit 9113a28

Please sign in to comment.