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
@@ -59,7 +59,8 @@ func (s *Store) RenamePathsInDomainChecked(domainUUID, oldPath, newPath string,
|
||||
return count, pathMutationTransactionError(err)
|
||||
}
|
||||
|
||||
func (s *Store) renamePathsInDomain(domainUUID, oldPath, newPath string, recursive bool, snapshot *PathMutationSnapshot) (int, error) {
|
||||
func (s *Store) renamePathsInDomain(domainUUID, oldPath, newPath string, recursive bool, snapshot *PathMutationSnapshot) (_ int, resultErr error) {
|
||||
defer func() { resultErr = s.cityMutationError("rename paths", resultErr) }()
|
||||
if err := s.ensureLocalDomain(domainUUID); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -72,13 +73,14 @@ func (s *Store) renamePathsInDomain(domainUUID, oldPath, newPath string, recursi
|
||||
return 0, ErrPathConflict
|
||||
}
|
||||
|
||||
tx, err := s.DB.Begin()
|
||||
tx, cancel, err := s.beginPathMutation(domainUUID)
|
||||
defer cancel()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
renames, err := listMutationPaths(tx, domainUUID, oldPath, recursive)
|
||||
renames, err := s.listMutationPaths(tx, domainUUID, oldPath, recursive)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -102,7 +104,7 @@ func (s *Store) renamePathsInDomain(domainUUID, oldPath, newPath string, recursi
|
||||
var exists int
|
||||
if err := tx.QueryRow(`
|
||||
SELECT COUNT(*) FROM paths
|
||||
WHERE domain_uuid = ? AND path = ?
|
||||
WHERE domain_uuid = `+s.sqlParam(1)+` AND path = `+s.sqlParam(2)+`
|
||||
`, domainUUID, item.NewPath).Scan(&exists); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -117,22 +119,22 @@ func (s *Store) renamePathsInDomain(domainUUID, oldPath, newPath string, recursi
|
||||
if _, err := tx.Exec(`
|
||||
INSERT INTO paths (
|
||||
domain_uuid, path, object_uuid, created_at, is_primary
|
||||
) VALUES (?, ?, ?, ?, ?)
|
||||
) VALUES (`+s.sqlValues(5)+`)
|
||||
`, domainUUID, item.NewPath, item.ObjectUUID, item.CreatedAt, item.IsPrimary); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
if err := renameUserSpacePathPoliciesTx(tx, domainUUID, oldPath, newPath, recursive); err != nil {
|
||||
if err := s.renameUserSpacePathPoliciesTx(tx, domainUUID, oldPath, newPath, recursive); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
for _, item := range renames {
|
||||
if _, err := tx.Exec(`
|
||||
DELETE FROM paths WHERE domain_uuid = ? AND path = ?
|
||||
DELETE FROM paths WHERE domain_uuid = `+s.sqlParam(1)+` AND path = `+s.sqlParam(2)+`
|
||||
`, domainUUID, item.OldPath); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
if err := renameBrowserNavigationPathsTx(tx, domainUUID, oldPath, newPath, recursive); err != nil {
|
||||
if err := s.renameBrowserNavigationPathsTx(tx, domainUUID, oldPath, newPath, recursive); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -145,8 +147,9 @@ func (s *Store) renamePathsInDomain(domainUUID, oldPath, newPath string, recursi
|
||||
}
|
||||
}
|
||||
for objectUUID, names := range renamedObjects {
|
||||
if err := cloneLatestRevisionFilenames(
|
||||
if err := s.cloneLatestRevisionFilenames(
|
||||
tx,
|
||||
domainUUID,
|
||||
objectUUID,
|
||||
names[0],
|
||||
names[1],
|
||||
@@ -155,12 +158,12 @@ func (s *Store) renamePathsInDomain(domainUUID, oldPath, newPath string, recursi
|
||||
}
|
||||
}
|
||||
if recursive {
|
||||
changed, err := renameCityPathPrefixesTx(tx, domainUUID, oldPath, newPath)
|
||||
changed, err := s.renameCityPathPrefixesTx(tx, domainUUID, oldPath, newPath)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if changed > 0 {
|
||||
if err := bumpTopologyVersion(tx, domainUUID, "system:path-rename", "city.paths.renamed", "path", oldPath); err != nil {
|
||||
if err := s.bumpTopologyVersion(tx, domainUUID, "system:path-rename", "city.paths.renamed", "path", oldPath); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
@@ -275,13 +278,23 @@ func (s *Store) RemovePath(path string) error {
|
||||
return s.RemovePathInDomain(domainUUID, path)
|
||||
}
|
||||
|
||||
func (s *Store) RemovePathInDomain(domainUUID, path string) error {
|
||||
func (s *Store) RemovePathInDomain(domainUUID, path string) (resultErr error) {
|
||||
defer func() { resultErr = s.sqlError("remove path", resultErr) }()
|
||||
if err := s.ensureLocalDomain(domainUUID); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := s.DB.Exec(`
|
||||
DELETE FROM paths WHERE domain_uuid = ? AND path = ?
|
||||
tx, cancel, err := s.beginPathMutation(domainUUID)
|
||||
defer cancel()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
_, err = tx.Exec(`
|
||||
DELETE FROM paths WHERE domain_uuid = `+s.sqlParam(1)+` AND path = `+s.sqlParam(2)+`
|
||||
`, domainUUID, normalizePath(path))
|
||||
if err == nil {
|
||||
err = tx.Commit()
|
||||
}
|
||||
if err == nil {
|
||||
s.InvalidatePathCaches()
|
||||
}
|
||||
@@ -306,7 +319,8 @@ func (s *Store) CopyPathsInDomainChecked(domainUUID, sourcePath, destinationPath
|
||||
return count, pathMutationTransactionError(err)
|
||||
}
|
||||
|
||||
func (s *Store) copyPathsInDomain(domainUUID, sourcePath, destinationPath string, recursive bool, snapshot *PathMutationSnapshot) (int, error) {
|
||||
func (s *Store) copyPathsInDomain(domainUUID, sourcePath, destinationPath string, recursive bool, snapshot *PathMutationSnapshot) (_ int, resultErr error) {
|
||||
defer func() { resultErr = s.sqlError("copy paths", resultErr) }()
|
||||
if err := s.ensureLocalDomain(domainUUID); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -318,12 +332,13 @@ func (s *Store) copyPathsInDomain(domainUUID, sourcePath, destinationPath string
|
||||
if recursive && strings.HasPrefix(destinationPath+"/", sourcePath+"/") {
|
||||
return 0, ErrPathConflict
|
||||
}
|
||||
tx, err := s.DB.Begin()
|
||||
tx, cancel, err := s.beginPathMutation(domainUUID)
|
||||
defer cancel()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
paths, err := listMutationPaths(tx, domainUUID, sourcePath, recursive)
|
||||
paths, err := s.listMutationPaths(tx, domainUUID, sourcePath, recursive)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -340,7 +355,7 @@ func (s *Store) copyPathsInDomain(domainUUID, sourcePath, destinationPath string
|
||||
}
|
||||
for _, item := range paths {
|
||||
var exists int
|
||||
if err := tx.QueryRow(`SELECT COUNT(*) FROM paths WHERE domain_uuid=? AND path=?`,
|
||||
if err := tx.QueryRow(`SELECT COUNT(*) FROM paths WHERE domain_uuid=`+s.sqlParam(1)+` AND path=`+s.sqlParam(2),
|
||||
domainUUID, item.NewPath).Scan(&exists); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -356,11 +371,15 @@ func (s *Store) copyPathsInDomain(domainUUID, sourcePath, destinationPath string
|
||||
objectCopies[item.ObjectUUID] = newObjectUUID
|
||||
if _, err := tx.Exec(`
|
||||
INSERT INTO objects (uuid, kind, created_at)
|
||||
SELECT ?, kind, ? FROM objects WHERE uuid=?`,
|
||||
SELECT `+s.sqlParam(1)+`, kind, `+s.sqlParam(2)+` FROM objects WHERE uuid=`+s.sqlParam(3),
|
||||
newObjectUUID, time.Now().Unix(), item.ObjectUUID); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if _, err := tx.Exec(`
|
||||
if s.sqlBackend == storePostgreSQL {
|
||||
if err := s.copyNativeRevisionsTx(tx, domainUUID, item.ObjectUUID, newObjectUUID, item.NewPath); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
} else if _, err := tx.Exec(`
|
||||
INSERT INTO revisions (
|
||||
uuid, object_uuid, body, document_hash, lang, content_type,
|
||||
filename, message, created_at_ms, created_at
|
||||
@@ -378,7 +397,7 @@ func (s *Store) copyPathsInDomain(domainUUID, sourcePath, destinationPath string
|
||||
}
|
||||
if _, err := tx.Exec(`
|
||||
INSERT INTO paths(domain_uuid,path,object_uuid,created_at,is_primary)
|
||||
VALUES(?,?,?,?,?)`,
|
||||
VALUES(`+s.sqlValues(5)+`)`,
|
||||
domainUUID, item.NewPath, newObjectUUID, time.Now().Unix(), item.IsPrimary); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user