Path remapping for packing

This commit changes how relative paths are handled depending on weather they are nested or not.

Layout is as follows.

- ./shots/01/shot_01.blend
- ./shots/01/maps/special.png
- ./maps/generic.png

Maps to...
- ./shot_01.blend
- ./_maps/special.png
- ./maps/generic.png
This commit is contained in:
2014-11-26 18:47:21 +01:00
parent afcb6acf5d
commit 673b0b0187
4 changed files with 146 additions and 39 deletions

View File

@@ -356,13 +356,19 @@ class FileAPI(Resource):
paths_uuid = {}
if filepath.endswith(".blend"):
# find the path relative to the project's root
blendfile_src_dir_fakeroot = os.path.dirname(os.path.relpath(filepath, paths_remap_relbase))
try:
yield from blendfile_pack.pack(
filepath.encode('utf-8'), filepath_zip.encode('utf-8'), mode='ZIP',
paths_remap_relbase=paths_remap_relbase.encode('utf-8'),
# TODO(cam) this just means the json is written in the zip
deps_remap=deps_remap, paths_remap=paths_remap, paths_uuid=paths_uuid,
report=report)
report=report,
blendfile_src_dir_fakeroot=blendfile_src_dir_fakeroot.encode('utf-8'),
)
except:
log.exception("Error packing the blend file")
return