edit: check for editor error

This commit is contained in:
Sina Siadat 2015-05-08 16:16:07 +04:30
parent 53b387ce03
commit cfafb28969

View File

@ -398,13 +398,14 @@ func (attr Attr) IncrementFrequency(db *sql.DB) (rowsAffected int64) {
} }
func (attr Attr) Edit(db *sql.DB) (rowsAffected int64) { func (attr Attr) Edit(db *sql.DB) (rowsAffected int64) {
// f, err := ioutil.TempFile("", "eton-edit")
// check(err)
// writeToFile(f.Name(), attr.GetValue())
filepath := attr.Filepath() filepath := attr.Filepath()
openEditor(filepath) if openEditor(filepath) == false {
return
}
value_text := readFile(filepath) value_text := readFile(filepath)
if value_text != attr.GetValue() { if value_text != attr.GetValue() {
update_stmt, err := db.Prepare("UPDATE attributes SET value_text = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?") update_stmt, err := db.Prepare("UPDATE attributes SET value_text = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?")
check(err) check(err)