Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep temp files to avoid losing data #90

Merged
merged 1 commit into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions simplenote_cli/sncli.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def exec_cmd_on_note(self, note, cmd=None, raw=False):
subprocess.check_call(cmd_list)
except Exception as e:
self.log('Command error: ' + str(e))
temp.tempfile_delete(tf)
self.log('Temp file saved: {}'.format(temp.tempfile_name(tf)))
return None

content = None
Expand All @@ -129,7 +129,7 @@ def exec_cmd_on_note(self, note, cmd=None, raw=False):
if not content or content == '\n':
content = None

temp.tempfile_delete(tf)
self.log('Temp file saved: {}'.format(temp.tempfile_name(tf)))
return content

def exec_diff_on_note(self, note, old_note):
Expand Down
4 changes: 2 additions & 2 deletions simplenote_cli/temp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def tempfile_create(note, raw=False, tempdir=None):
if raw:
# dump the raw json of the note
tf = tempfile.NamedTemporaryFile(suffix='.json', delete=False, dir=tempdir)
tf = tempfile.NamedTemporaryFile(suffix='.json', prefix="sncli-temp-", delete=False, dir=tempdir)

contents = json.dumps(note, indent=2)
tf.write(contents.encode('utf-8'))
Expand All @@ -18,7 +18,7 @@ def tempfile_create(note, raw=False, tempdir=None):
'systemTags' in note and \
'markdown' in note['systemTags']:
ext = '.mkd'
tf = tempfile.NamedTemporaryFile(suffix=ext, delete=False, dir=tempdir)
tf = tempfile.NamedTemporaryFile(suffix=ext, prefix="sncli-temp-", delete=False, dir=tempdir)
if note:
contents = note['content']
tf.write(contents.encode('utf-8'))
Expand Down