feat(storage): add native PostgreSQL runtime and verified offline application import
Build and publish container images / images (push) Failing after 12m29s
Build and publish container images / images (push) Failing after 12m29s
This commit is contained in:
1 parent
96065d1e89
commit
0ba1dcfef0
243 files changed
+21441
-3090
No files matched your search
@@ -26,9 +26,7 @@ func (s *Server) appearanceForRequest(r *http.Request) personalAppearance {
|
||||
if principal == nil {
|
||||
return p
|
||||
}
|
||||
var raw string
|
||||
var version int64
|
||||
if s.store.DB.QueryRowContext(r.Context(), `SELECT version,data FROM personal_appearance WHERE domain_uuid=? AND owner_uuid=?`, domain, principal.UUID).Scan(&version, &raw) == nil {
|
||||
if version, raw, err := s.store.PersonalAppearance(r.Context(), domain, principal.UUID); err == nil {
|
||||
var saved personalAppearance
|
||||
if json.Unmarshal([]byte(raw), &saved) == nil {
|
||||
saved.Version = version
|
||||
@@ -93,20 +91,7 @@ func (s *Server) savePersonalAppearance(w http.ResponseWriter, r *http.Request,
|
||||
}
|
||||
p.Version = version + 1
|
||||
raw, _ := json.Marshal(p)
|
||||
result, err := s.store.DB.ExecContext(r.Context(), `INSERT INTO personal_appearance(domain_uuid,owner_uuid,version,data) SELECT ?,?,?,? WHERE ?=0 ON CONFLICT(domain_uuid,owner_uuid) DO NOTHING`, domain, actor, p.Version, string(raw), version)
|
||||
if err == nil {
|
||||
var n int64
|
||||
n, err = result.RowsAffected()
|
||||
if err == nil && n == 0 {
|
||||
result, err = s.store.DB.ExecContext(r.Context(), `UPDATE personal_appearance SET version=?,data=? WHERE domain_uuid=? AND owner_uuid=? AND version=?`, p.Version, string(raw), domain, actor, version)
|
||||
if err == nil {
|
||||
n, err = result.RowsAffected()
|
||||
if n == 0 {
|
||||
err = sql.ErrNoRows
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
err = s.store.SavePersonalAppearance(r.Context(), domain, actor, version, string(raw))
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
http.Error(w, "Settings changed elsewhere; reload before saving.", 409)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user