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
+18
-16
@@ -65,9 +65,9 @@ func (s *Store) ensureTaskDAVSchema() error {
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
func syncTaskDAVTx(ctx context.Context, tx *sql.Tx, domain, actor string, item TaskRecord) error {
|
||||
func (s *Store) syncTaskDAVTx(ctx context.Context, tx *sql.Tx, domain, actor string, item TaskRecord) error {
|
||||
if item.Kind == "project" {
|
||||
_, err := tx.ExecContext(ctx, `INSERT INTO organizer_dav_collections(domain_uuid,path,owner_uuid,project_uuid) VALUES(?,?,?,?) ON CONFLICT(domain_uuid,project_uuid) DO NOTHING`, domain, item.TaskDAVCollectionPath(), actor, item.UUID)
|
||||
_, err := tx.ExecContext(ctx, `INSERT INTO organizer_dav_collections(domain_uuid,path,owner_uuid,project_uuid) VALUES(`+s.sqlParam(1)+`,`+s.sqlParam(2)+`,`+s.sqlParam(3)+`,`+s.sqlParam(4)+`) ON CONFLICT(domain_uuid,project_uuid) DO NOTHING`, domain, item.TaskDAVCollectionPath(), actor, item.UUID)
|
||||
return err
|
||||
}
|
||||
if item.Kind != "task" {
|
||||
@@ -77,31 +77,33 @@ func syncTaskDAVTx(ctx context.Context, tx *sql.Tx, domain, actor string, item T
|
||||
if item.CalDAV != nil {
|
||||
name, uid = item.CalDAV.Name, item.CalDAV.UID
|
||||
}
|
||||
project, err := taskDAVProjectTx(ctx, tx, domain, actor, item.ProjectUUID)
|
||||
project, err := s.taskDAVProjectTx(ctx, tx, domain, actor, item.ProjectUUID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
name, uid = taskDAVIndexKey(project, name), taskDAVIndexKey(project, uid)
|
||||
name, uid = s.taskDAVIndexKey(project, name), s.taskDAVIndexKey(project, uid)
|
||||
var collision bool
|
||||
if err := tx.QueryRowContext(ctx, `SELECT EXISTS(SELECT 1 FROM organizer_dav_resources WHERE domain_uuid=? AND owner_uuid=? AND item_uuid<>? AND (name=? OR uid=?))`, domain, actor, item.UUID, name, uid).Scan(&collision); err != nil {
|
||||
if err := tx.QueryRowContext(ctx, `SELECT EXISTS(SELECT 1 FROM organizer_dav_resources WHERE domain_uuid=`+s.sqlParam(1)+` AND owner_uuid=`+s.sqlParam(2)+` AND item_uuid<>`+s.sqlParam(3)+` AND (name=`+s.sqlParam(4)+` OR uid=`+s.sqlParam(5)+`))`, domain, actor, item.UUID, name, uid).Scan(&collision); err != nil {
|
||||
return err
|
||||
}
|
||||
if collision {
|
||||
return ErrTaskDAVIdentity
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `INSERT INTO organizer_dav_resources(domain_uuid,owner_uuid,item_uuid,name,uid) VALUES(?,?,?,?,?) ON CONFLICT(domain_uuid,item_uuid) DO UPDATE SET name=excluded.name,uid=excluded.uid`, domain, actor, item.UUID, name, uid)
|
||||
_, err = tx.ExecContext(ctx, `INSERT INTO organizer_dav_resources(domain_uuid,owner_uuid,item_uuid,name,uid) VALUES(`+s.sqlParam(1)+`,`+s.sqlParam(2)+`,`+s.sqlParam(3)+`,`+s.sqlParam(4)+`,`+s.sqlParam(5)+`) ON CONFLICT(domain_uuid,item_uuid) DO UPDATE SET name=excluded.name,uid=excluded.uid`, domain, actor, item.UUID, name, uid)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) TaskDAVByName(ctx context.Context, domain, actor, name string, project ...string) (TaskRecord, error) {
|
||||
if err := taskActor(ctx, s.DB, domain, actor, false); err != nil {
|
||||
if err := s.taskActor(ctx, s.DB, domain, actor, false); err != nil {
|
||||
return TaskRecord{}, err
|
||||
}
|
||||
var id string
|
||||
p := ""
|
||||
if len(project) == 1 {
|
||||
name = taskDAVIndexKey(project[0], name)
|
||||
p = project[0]
|
||||
}
|
||||
if err := s.DB.QueryRowContext(ctx, `SELECT item_uuid FROM organizer_dav_resources WHERE domain_uuid=? AND owner_uuid=? AND name=?`, domain, actor, name).Scan(&id); err != nil {
|
||||
name = s.taskDAVIndexKey(p, name)
|
||||
if err := s.DB.QueryRowContext(ctx, `SELECT item_uuid FROM organizer_dav_resources WHERE domain_uuid=`+s.sqlParam(1)+` AND owner_uuid=`+s.sqlParam(2)+` AND name=`+s.sqlParam(3)+``, domain, actor, name).Scan(&id); err != nil {
|
||||
return TaskRecord{}, err
|
||||
}
|
||||
return s.GetTask(ctx, domain, actor, id)
|
||||
@@ -110,17 +112,17 @@ func (s *Store) TaskDAVByName(ctx context.Context, domain, actor, name string, p
|
||||
// A complete bounded snapshot, including completed tasks. Never silently return
|
||||
// a partial collection: synchronizers would mistake omitted resources for deletes.
|
||||
func (s *Store) TaskDAVList(ctx context.Context, domain, actor string, project ...string) ([]TaskRecord, error) {
|
||||
if err := taskActor(ctx, s.DB, domain, actor, false); err != nil {
|
||||
if err := s.taskActor(ctx, s.DB, domain, actor, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p := ""
|
||||
if len(project) == 1 {
|
||||
p = project[0]
|
||||
}
|
||||
query := `SELECT data FROM organizer_items i WHERE domain_uuid=? AND owner_uuid=? AND kind='task' AND archived=0`
|
||||
query := `SELECT data FROM organizer_items i WHERE domain_uuid=` + s.sqlParam(1) + ` AND owner_uuid=` + s.sqlParam(2) + ` AND kind='task' AND archived=0`
|
||||
args := []any{domain, actor}
|
||||
if p != "" {
|
||||
query += ` AND project_uuid=?`
|
||||
query += ` AND project_uuid=` + s.sqlParam(len(args)+1) + ``
|
||||
args = append(args, p)
|
||||
} else {
|
||||
query += ` AND project_uuid=''`
|
||||
@@ -153,7 +155,7 @@ func (s *Store) TaskDAVList(ctx context.Context, domain, actor string, project .
|
||||
func (s *Store) SaveTaskDAV(ctx context.Context, domain, actor string, item TaskRecord, expected int64, data *TaskDAVData, credential string, collectionProject ...string) (TaskRecord, error) {
|
||||
return s.saveTask(ctx, domain, actor, item, expected, func(tx *sql.Tx, v *TaskRecord, old TaskRecord) error {
|
||||
if credential != "" {
|
||||
if err := taskDAVCredentialAllowed(ctx, tx, domain, actor, credential, true); err != nil {
|
||||
if err := s.taskDAVCredentialAllowed(ctx, tx, domain, actor, credential, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -161,7 +163,7 @@ func (s *Store) SaveTaskDAV(ctx context.Context, domain, actor string, item Task
|
||||
return ErrTaskInvalid
|
||||
}
|
||||
if len(collectionProject) == 1 {
|
||||
p, err := taskDAVProjectTx(ctx, tx, domain, actor, v.ProjectUUID)
|
||||
p, err := s.taskDAVProjectTx(ctx, tx, domain, actor, v.ProjectUUID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -170,7 +172,7 @@ func (s *Store) SaveTaskDAV(ctx context.Context, domain, actor string, item Task
|
||||
}
|
||||
if p != "" {
|
||||
var active bool
|
||||
if err := tx.QueryRowContext(ctx, `SELECT archived=0 FROM organizer_items WHERE domain_uuid=? AND owner_uuid=? AND uuid=?`, domain, actor, p).Scan(&active); err != nil {
|
||||
if err := tx.QueryRowContext(ctx, `SELECT archived=0 FROM organizer_items WHERE domain_uuid=`+s.sqlParam(1)+` AND owner_uuid=`+s.sqlParam(2)+` AND uuid=`+s.sqlParam(3)+``, domain, actor, p).Scan(&active); err != nil {
|
||||
return err
|
||||
}
|
||||
if !active {
|
||||
@@ -192,7 +194,7 @@ func (s *Store) SaveTaskDAV(ctx context.Context, domain, actor string, item Task
|
||||
}
|
||||
} else if v.ProjectUUID == "" {
|
||||
var relocated bool
|
||||
if err := tx.QueryRowContext(ctx, `SELECT EXISTS(SELECT 1 FROM organizer_dav_legacy_hrefs WHERE domain_uuid=? AND owner_uuid=? AND name=?)`, domain, actor, data.Name).Scan(&relocated); err != nil {
|
||||
if err := tx.QueryRowContext(ctx, `SELECT EXISTS(SELECT 1 FROM organizer_dav_legacy_hrefs WHERE domain_uuid=`+s.sqlParam(1)+` AND owner_uuid=`+s.sqlParam(2)+` AND name=`+s.sqlParam(3)+`)`, domain, actor, data.Name).Scan(&relocated); err != nil {
|
||||
return err
|
||||
}
|
||||
if relocated {
|
||||
|
||||
Reference in new issue
Block a user