Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming. Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
38 lines
686 B
Go
38 lines
686 B
Go
package store
|
|
|
|
import "database/sql"
|
|
|
|
func (s *Store) DeleteObject(
|
|
objectUUID string,
|
|
) error {
|
|
|
|
tx, err :=
|
|
s.DB.Begin()
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer tx.Rollback()
|
|
if err := deleteObjectTx(tx, objectUUID); err != nil {
|
|
return err
|
|
}
|
|
if err := tx.Commit(); err != nil {
|
|
return err
|
|
}
|
|
s.InvalidatePathCaches()
|
|
return nil
|
|
}
|
|
|
|
func deleteObjectTx(tx *sql.Tx, objectUUID string) error {
|
|
for _, table := range []string{"paths", "tags", "revisions", "objects"} {
|
|
column := "object_uuid"
|
|
if table == "objects" {
|
|
column = "uuid"
|
|
}
|
|
if _, err := tx.Exec(`DELETE FROM `+table+` WHERE `+column+` = ?`, objectUUID); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|