support for checking out non-blend files

This commit is contained in:
2014-11-19 16:39:06 +01:00
parent a5646eeeb9
commit 1b5568256c

View File

@@ -322,17 +322,31 @@ class FileAPI(Resource):
paths_remap = {} paths_remap = {}
paths_uuid = {} paths_uuid = {}
try: if filepath.endswith(".blend"):
yield from blendfile_pack.pack( try:
filepath.encode('utf-8'), filepath_zip.encode('utf-8'), mode='ZIP', yield from blendfile_pack.pack(
paths_remap_relbase=paths_remap_relbase.encode('utf-8'), filepath.encode('utf-8'), filepath_zip.encode('utf-8'), mode='ZIP',
# TODO(cam) this just means the json is written in the zip paths_remap_relbase=paths_remap_relbase.encode('utf-8'),
deps_remap=deps_remap, paths_remap=paths_remap, paths_uuid=paths_uuid, # TODO(cam) this just means the json is written in the zip
report=report) deps_remap=deps_remap, paths_remap=paths_remap, paths_uuid=paths_uuid,
except: report=report)
import traceback except:
traceback.print_exc() import traceback
return traceback.print_exc()
return
else:
# non blend-file
from bam_utils.system import sha1_from_file
paths_uuid[os.path.basename(filepath)] = sha1_from_file(filepath)
del sha1_from_file
import zipfile
with zipfile.ZipFile(filepath_zip, 'w', zipfile.ZIP_DEFLATED) as zip_handle:
zip_handle.write(
filepath,
arcname=os.path.basename(filepath),
)
del zipfile
# TODO, avoid reopening zipfile # TODO, avoid reopening zipfile
# append json info to zip # append json info to zip