Skip to content

Commit

Permalink
Merge pull request #23 from yumiguan/feature/support-save-draft-in-sa…
Browse files Browse the repository at this point in the history
…me-name

feature/support-save-draft-in-same-name
  • Loading branch information
yumiguan authored Oct 28, 2021
2 parents 8d9b7c6 + 7b8da45 commit 658e8db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
5 changes: 0 additions & 5 deletions lyrebird_bugit/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,6 @@ def ui_cache(template_key):
if 'extraMsg' in field:
del field['extraMsg']

all_drafts = cache.get_draft_list(template_key)
for draft in all_drafts:
if draft.get('cacheName') == cache_name:
return application.make_fail_response('Duplicated draft name!')

draft_name = cache.get_filename(template_path, cache_name)
cache.put(draft_name, template_detail)
cache.put(f'{draft_name}{cache.DRAFT_INFO_FILE_SUFFIX}', {'cache_name': cache_name})
Expand Down
14 changes: 10 additions & 4 deletions lyrebird_bugit/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ def _check_dir():

def export_snapshot(snapshot):
_check_dir()
file_content = requests.post(EXPORT_URL,json=snapshot['eventObj'],stream=True).content
res = requests.post(EXPORT_URL, json=snapshot['eventObj'], stream=True)
# SnapshotId is unique id of snapshot
id_ = res.headers.get('SnapshotId')
with codecs.open(str(ATTACHMENT_ROOT / snapshot['name'])+'.lb', 'wb') as f:
f.write(file_content)
return {'id':snapshot['eventObj']['id'],'name':snapshot['name']+'.lb',
'path':str(ATTACHMENT_ROOT / snapshot['name'])+'.lb'}
for chunck in res.iter_content():
f.write(chunck)
return {
'id': id_,
'name': snapshot['name']+'.lb',
'path': str(ATTACHMENT_ROOT / snapshot['name'])+'.lb',
}

def remove_attach():
if not ATTACHMENT_ROOT.exists():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='lyrebird-bugit',
version='1.8.0',
version='1.8.1',
packages=['lyrebird_bugit'],
url='https://github.com/Meituan-Dianping/lyrebird-bugit',
author='HBQA',
Expand Down

0 comments on commit 658e8db

Please sign in to comment.