Refactor snapshot parent updates: replace full metadata reload with UpdateSnapshotParentID method, enhance functional test logging, and add CleanOnRestore option.
This commit is contained in:
@ -265,3 +265,13 @@ func (s *sqliteStore) DeleteSnapshotMetadata(ctx context.Context, snapshotID str
|
||||
|
||||
return nil // Не возвращаем ошибку, если запись не найдена
|
||||
}
|
||||
|
||||
// UpdateSnapshotParentID обновляет ParentID для указанного снапшота.
|
||||
func (s *sqliteStore) UpdateSnapshotParentID(ctx context.Context, snapshotID, newParentID string) error {
|
||||
query := `UPDATE snapshots SET parent_id = ? WHERE id = ?;`
|
||||
_, err := s.db.ExecContext(ctx, query, newParentID, snapshotID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update parent ID for snapshot %s: %w", snapshotID, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -55,6 +55,9 @@ type MetadataStore interface {
|
||||
// Не должен возвращать ошибку, если снапшот не найден.
|
||||
DeleteSnapshotMetadata(ctx context.Context, snapshotID string) error
|
||||
|
||||
// UpdateSnapshotParentID обновляет ParentID для указанного снапшота.
|
||||
UpdateSnapshotParentID(ctx context.Context, snapshotID, newParentID string) error
|
||||
|
||||
// Close закрывает соединение с хранилищем метаданных.
|
||||
Close() error
|
||||
}
|
||||
|
Reference in New Issue
Block a user