use create_hard_link instead of filelink

This commit is contained in:
Jakub Trllo 2022-03-07 14:50:14 +01:00
parent 8088534caa
commit c57fc03916
3 changed files with 10 additions and 9 deletions

View file

@ -71,15 +71,14 @@ def path_from_representation(representation, anatomy):
def copy_file(src_path, dst_path): def copy_file(src_path, dst_path):
"""Hardlink file if possible(to save space), copy if not""" """Hardlink file if possible(to save space), copy if not"""
from avalon.vendor import filelink # safer importing from openpype.lib import create_hard_link # safer importing
if os.path.exists(dst_path): if os.path.exists(dst_path):
return return
try: try:
filelink.create( create_hard_link(
src_path, src_path,
dst_path, dst_path
filelink.HARDLINK
) )
except OSError: except OSError:
shutil.copyfile(src_path, dst_path) shutil.copyfile(src_path, dst_path)

View file

@ -7,7 +7,7 @@ import shutil
from pymongo import InsertOne, ReplaceOne from pymongo import InsertOne, ReplaceOne
import pyblish.api import pyblish.api
from avalon import api, io, schema from avalon import api, io, schema
from avalon.vendor import filelink from openpype.lib import create_hard_link
class IntegrateHeroVersion(pyblish.api.InstancePlugin): class IntegrateHeroVersion(pyblish.api.InstancePlugin):
@ -518,7 +518,7 @@ class IntegrateHeroVersion(pyblish.api.InstancePlugin):
# First try hardlink and copy if paths are cross drive # First try hardlink and copy if paths are cross drive
try: try:
filelink.create(src_path, dst_path, filelink.HARDLINK) create_hard_link(src_path, dst_path)
# Return when successful # Return when successful
return return

View file

@ -13,12 +13,14 @@ from pymongo import DeleteOne, InsertOne
import pyblish.api import pyblish.api
from avalon import io from avalon import io
from avalon.api import format_template_with_optional_keys from avalon.api import format_template_with_optional_keys
from avalon.vendor import filelink
import openpype.api import openpype.api
from datetime import datetime from datetime import datetime
# from pype.modules import ModulesManager # from pype.modules import ModulesManager
from openpype.lib.profiles_filtering import filter_profiles from openpype.lib.profiles_filtering import filter_profiles
from openpype.lib import prepare_template_data from openpype.lib import (
prepare_template_data,
create_hard_link
)
# this is needed until speedcopy for linux is fixed # this is needed until speedcopy for linux is fixed
if sys.platform == "win32": if sys.platform == "win32":
@ -730,7 +732,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
self.log.critical("An unexpected error occurred.") self.log.critical("An unexpected error occurred.")
six.reraise(*sys.exc_info()) six.reraise(*sys.exc_info())
filelink.create(src, dst, filelink.HARDLINK) create_hard_link(src, dst)
def get_subset(self, asset, instance): def get_subset(self, asset, instance):
subset_name = instance.data["subset"] subset_name = instance.data["subset"]