Merge pull request #693 from taigaio/Allowing-export-project-even-if-any-file-doesnt-exist
Allowing export projects even if any attachment doesn't exist in the …remotes/origin/issue/4795/notification_even_they_are_disabled
commit
dd4fc1b351
|
@ -111,14 +111,15 @@ def render_project(project, outfile, chunk_size = 8190):
|
||||||
|
|
||||||
# We write the attached_files by chunks so the memory used is not increased
|
# We write the attached_files by chunks so the memory used is not increased
|
||||||
attachment_file = attachment.attached_file
|
attachment_file = attachment.attached_file
|
||||||
with default_storage.open(attachment_file.name) as f:
|
if default_storage.exists(attachment_file.name):
|
||||||
while True:
|
with default_storage.open(attachment_file.name) as f:
|
||||||
bin_data = f.read(chunk_size)
|
while True:
|
||||||
if not bin_data:
|
bin_data = f.read(chunk_size)
|
||||||
break
|
if not bin_data:
|
||||||
|
break
|
||||||
|
|
||||||
b64_data = base64.b64encode(bin_data).decode('utf-8')
|
b64_data = base64.b64encode(bin_data).decode('utf-8')
|
||||||
outfile.write(b64_data)
|
outfile.write(b64_data)
|
||||||
|
|
||||||
outfile.write('", \n "name":"{}"}}\n}}'.format(
|
outfile.write('", \n "name":"{}"}}\n}}'.format(
|
||||||
os.path.basename(attachment_file.name)))
|
os.path.basename(attachment_file.name)))
|
||||||
|
|
Loading…
Reference in New Issue