Snippet update errors discards changes

Summary

When updating a snippet (personal or project) if there is a repository related error (e.g. an invalid file name has been used), all changes made will be reverted, which could be super frustrating for users.

Steps to reproduce

  • Create a snippet (personal or project)
  • Edit the snippet
    • Change content to something new
    • Change filename to invalid://path
    • Hit save
  • Content and filename changes will have been reverted on resulting view

What is the current bug behavior?

Changes are lost

What is the expected correct behavior?

Changes should not be lost, so the user doesn't lose their changes

Relevant logs and/or screenshots

2020-05-13_09.25.32

Possible fixes

I think this block is the cause of the issue because it means any changes the user has made will be reverted.

Edited by Vijay Hawoldar