Skip to content

Support integrating a folder as files for a representation #1113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion client/ayon_core/lib/file_transaction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import logging
import shutil
import sys
import errno

Expand Down Expand Up @@ -135,7 +136,10 @@ def process(self):

self._create_folder_for_file(dst)

if opts["mode"] == self.MODE_COPY:
if os.path.isdir(src):
self.log.debug(f"Copying directory ... {src} -> {dst}")
shutil.copytree(src, dst)
elif opts["mode"] == self.MODE_COPY:
self.log.debug("Copying file ... {} -> {}".format(src, dst))
copyfile(src, dst)
elif opts["mode"] == self.MODE_HARDLINK:
Expand Down
6 changes: 6 additions & 0 deletions client/ayon_core/pipeline/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ def _copy_file(src_path, dst_path):

if os.path.exists(dst_path):
return

if os.path.isdir(src_path):
# Support representations that are directories
shutil.copytree(src_path, dst_path)
return

try:
create_hard_link(
src_path,
Expand Down
7 changes: 7 additions & 0 deletions client/ayon_core/plugins/publish/integrate_hero_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,13 @@ def copy_file(self, src_path, dst_path):

self.log.debug("Folder already exists: \"{}\"".format(dirname))

if os.path.isdir(src_path):
# Support representations that are directories
self.log.debug(
f"Copying directory \"{src_path}\" to \"{dst_path}\"")
shutil.copytree(src_path, dst_path)
return

if self.use_hardlinks:
# First try hardlink and copy if paths are cross drive
self.log.debug("Hardlinking file \"{}\" to \"{}\"".format(
Expand Down
6 changes: 5 additions & 1 deletion client/ayon_core/tools/workfiles/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,11 @@ def _save_as_workfile(
# Save workfile
dst_filepath = os.path.join(workdir, filename)
if src_filepath:
shutil.copyfile(src_filepath, dst_filepath)
# Support published workfile representations that may be folders
if os.path.isdir(src_filepath):
shutil.copytree(src_filepath, dst_filepath)
else:
shutil.copyfile(src_filepath, dst_filepath)
self._host_open_workfile(dst_filepath)
else:
self._host_save_workfile(dst_filepath)
Expand Down
Loading