diff --git a/CHANGELOG.md b/CHANGELOG.md index b2dcc35..ec3c8ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Blender Cloud changelog +## Version 1.15 (in development) + +- Avoid creating BAT pack when the to-be-rendered file is already inside the job storage + directory. This assumes that the paths are already correct for the Flamenco Workers. + + ## Version 1.14 (2019-10-10) - Upgraded BAT to 1.2 for missing smoke caches, compatibility with Blender 2.81, and some diff --git a/blender_cloud/flamenco/__init__.py b/blender_cloud/flamenco/__init__.py index 4d81326..3111686 100644 --- a/blender_cloud/flamenco/__init__.py +++ b/blender_cloud/flamenco/__init__.py @@ -240,6 +240,23 @@ def guess_output_file_extension(output_format: str, scene) -> str: return '.' + container.lower() +def is_file_inside_job_storage(prefs, current_file: Path) -> bool: + """Check whether current blend file is inside the storage path. + + :return: True when 'current_file' is inside the Flamenco + job storage directory already. In this case it won't be + BAT-packed, as it's assumed the job storage dir is + accessible by the workers already. + """ + flamenco_job_file_path = Path(prefs.flamenco_job_file_path).absolute().resolve() + current_file = current_file.absolute().resolve() + try: + current_file.relative_to(flamenco_job_file_path) + except ValueError: + return False + return True + + @compatibility.convert_properties class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin, pillar.AuthenticatedPillarOperatorMixin, @@ -596,6 +613,11 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin, outfile = PurePath('{shaman}') / outfile return None, outfile, missing_sources + if is_file_inside_job_storage(prefs, filepath): + # The blend file is contained in the job storage path, no need to copy anything. + # Since BAT doesn't run, we also don't know whether files are missing. + return filepath.parent, filepath, [] + # Create a unique directory that is still more or less identifyable. # This should work better than a random ID. unique_dir = '%s-%s-%s' % (datetime.now().isoformat('-').replace(':', ''), @@ -1043,6 +1065,12 @@ class FLAMENCO_PT_render(bpy.types.Panel, FlamencoPollMixin): text='', icon='DISK_DRIVE') props.path = prefs.flamenco_job_file_path + + if is_file_inside_job_storage(prefs, Path(context.blend_data.filepath)): + # File is contained in the job storage path, no need to copy anything. + paths_layout.label(text='Current file already in job storage path; ' + 'not going to create BAT pack.') + render_output = render_output_path(context) if render_output is None: paths_layout.label(text='Unable to render with Flamenco, outside of project directory.')