mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
Fix: Hardcoded main site and wrongly copied workfile (#5733)
This commit is contained in:
parent
1d02f46e15
commit
71a1365216
1 changed files with 40 additions and 42 deletions
|
|
@ -207,59 +207,57 @@ class CopyLastPublishedWorkfile(PreLaunchHook):
|
||||||
# Copy resources to the local resources directory
|
# Copy resources to the local resources directory
|
||||||
for file in workfile_representation['files']:
|
for file in workfile_representation['files']:
|
||||||
# Get resource main path
|
# Get resource main path
|
||||||
resource_main_path = file["path"].replace(
|
resource_main_path = anatomy.fill_root(file["path"])
|
||||||
"{root[main]}", str(anatomy.roots["main"])
|
|
||||||
)
|
# Get resource file basename
|
||||||
|
resource_basename = os.path.basename(resource_main_path)
|
||||||
|
|
||||||
# Only copy if the resource file exists, and it's not the workfile
|
# Only copy if the resource file exists, and it's not the workfile
|
||||||
if (
|
if (
|
||||||
not os.path.exists(resource_main_path)
|
not os.path.exists(resource_main_path)
|
||||||
and not resource_main_path != last_published_workfile_path
|
or resource_basename == os.path.basename(
|
||||||
|
last_published_workfile_path
|
||||||
|
)
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Get resource file basename
|
|
||||||
resource_basename = os.path.basename(resource_main_path)
|
|
||||||
|
|
||||||
# Get resource path in workfile folder
|
# Get resource path in workfile folder
|
||||||
resource_work_path = os.path.join(
|
resource_work_path = os.path.join(
|
||||||
resources_dir, resource_basename
|
resources_dir, resource_basename
|
||||||
)
|
)
|
||||||
if not os.path.exists(resource_work_path):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Check if the resource file already exists
|
# Check if the resource file already exists in the resources folder
|
||||||
# in the workfile resources folder,
|
if os.path.exists(resource_work_path):
|
||||||
# and both files are the same.
|
# Check if both files are the same
|
||||||
if filecmp.cmp(resource_main_path, resource_work_path):
|
if filecmp.cmp(resource_main_path, resource_work_path):
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
'Resource "{}" already exists.'
|
'Resource "{}" already exists.'
|
||||||
.format(resource_basename)
|
.format(resource_basename)
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
else:
|
|
||||||
# Add `.old` to existing resource path
|
|
||||||
resource_path_old = resource_work_path + '.old'
|
|
||||||
if os.path.exists(resource_work_path + '.old'):
|
|
||||||
for i in range(1, 100):
|
|
||||||
p = resource_path_old + '%02d' % i
|
|
||||||
if not os.path.exists(p):
|
|
||||||
# Rename existing resource file to
|
|
||||||
# `resource_name.old` + 2 digits
|
|
||||||
shutil.move(resource_work_path, p)
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
self.log.warning(
|
|
||||||
'There are a hundred old files for '
|
|
||||||
'resource "{}". '
|
|
||||||
'Perhaps is it time to clean up your '
|
|
||||||
'resources folder'
|
|
||||||
.format(resource_basename)
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
else:
|
else:
|
||||||
# Rename existing resource file to `resource_name.old`
|
# Add `.old` to existing resource path
|
||||||
shutil.move(resource_work_path, resource_path_old)
|
resource_path_old = resource_work_path + '.old'
|
||||||
|
if os.path.exists(resource_work_path + '.old'):
|
||||||
|
for i in range(1, 100):
|
||||||
|
p = resource_path_old + '%02d' % i
|
||||||
|
if not os.path.exists(p):
|
||||||
|
# Rename existing resource file to
|
||||||
|
# `resource_name.old` + 2 digits
|
||||||
|
shutil.move(resource_work_path, p)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
self.log.warning(
|
||||||
|
'There are a hundred old files for '
|
||||||
|
'resource "{}". '
|
||||||
|
'Perhaps is it time to clean up your '
|
||||||
|
'resources folder'
|
||||||
|
.format(resource_basename)
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
# Rename existing resource file to `resource_name.old`
|
||||||
|
shutil.move(resource_work_path, resource_path_old)
|
||||||
|
|
||||||
# Copy resource file to workfile resources folder
|
# Copy resource file to workfile resources folder
|
||||||
shutil.copy(resource_main_path, resources_dir)
|
shutil.copy(resource_main_path, resources_dir)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue