refactor: rename public package nouns
This commit is contained in:
parent
93177a7545
commit
2a0b49b2aa
@ -1,4 +1,4 @@
|
||||
package desktopcache
|
||||
package cache
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@ -1,4 +1,4 @@
|
||||
package desktopcache
|
||||
package cache
|
||||
|
||||
import (
|
||||
"os"
|
||||
@ -1,4 +1,4 @@
|
||||
package configkit
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@ -1,4 +1,4 @@
|
||||
package configkit
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
@ -1,4 +1,4 @@
|
||||
package gitshare
|
||||
package mirror
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -1,4 +1,4 @@
|
||||
package gitshare
|
||||
package mirror
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -1,4 +1,4 @@
|
||||
package cliout
|
||||
package output
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@ -1,4 +1,4 @@
|
||||
package cliout
|
||||
package output
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -1,4 +1,4 @@
|
||||
package pack
|
||||
package snapshot
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@ -15,7 +15,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/vincentkoc/crawlkit/sqlitekit"
|
||||
"github.com/vincentkoc/crawlkit/store"
|
||||
)
|
||||
|
||||
const ManifestName = "manifest.json"
|
||||
@ -153,7 +153,7 @@ func Import(ctx context.Context, opts ImportOptions) (Manifest, error) {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if _, err := tx.ExecContext(ctx, "delete from "+sqlitekit.QuoteIdent(table)); err != nil {
|
||||
if _, err := tx.ExecContext(ctx, "delete from "+store.QuoteIdent(table)); err != nil {
|
||||
return Manifest{}, fmt.Errorf("clear table %s: %w", table, err)
|
||||
}
|
||||
}
|
||||
@ -205,7 +205,7 @@ func WriteManifest(rootDir string, manifest Manifest) error {
|
||||
}
|
||||
|
||||
func exportTable(ctx context.Context, db *sql.DB, rootDir, table string, maxShardBytes int64, filter RowFilter) (TableManifest, error) {
|
||||
rows, err := db.QueryContext(ctx, "select * from "+sqlitekit.QuoteIdent(table))
|
||||
rows, err := db.QueryContext(ctx, "select * from "+store.QuoteIdent(table))
|
||||
if err != nil {
|
||||
return TableManifest{}, fmt.Errorf("query table %s: %w", table, err)
|
||||
}
|
||||
@ -324,13 +324,13 @@ func insertRow(ctx context.Context, tx *sql.Tx, table string, row map[string]any
|
||||
holders := make([]string, 0, len(cols))
|
||||
args := make([]any, 0, len(cols))
|
||||
for _, col := range cols {
|
||||
quoted = append(quoted, sqlitekit.QuoteIdent(col))
|
||||
quoted = append(quoted, store.QuoteIdent(col))
|
||||
holders = append(holders, "?")
|
||||
args = append(args, row[col])
|
||||
}
|
||||
stmt := fmt.Sprintf(
|
||||
"insert or replace into %s(%s) values(%s)",
|
||||
sqlitekit.QuoteIdent(table),
|
||||
store.QuoteIdent(table),
|
||||
strings.Join(quoted, ","),
|
||||
strings.Join(holders, ","),
|
||||
)
|
||||
@ -1,4 +1,4 @@
|
||||
package pack
|
||||
package snapshot
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -7,12 +7,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/vincentkoc/crawlkit/sqlitekit"
|
||||
"github.com/vincentkoc/crawlkit/store"
|
||||
)
|
||||
|
||||
func TestExportImportTablesWithFilter(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
src, err := sqlitekit.Open(ctx, sqlitekit.Options{
|
||||
src, err := store.Open(ctx, store.Options{
|
||||
Path: filepath.Join(t.TempDir(), "src.db"),
|
||||
Schema: `
|
||||
create table messages(id text primary key, guild_id text not null, body text not null);
|
||||
@ -44,7 +44,7 @@ create table sync_state(source_name text, entity_type text, entity_id text, valu
|
||||
t.Fatalf("manifest = %+v", manifest)
|
||||
}
|
||||
|
||||
dst, err := sqlitekit.Open(ctx, sqlitekit.Options{
|
||||
dst, err := store.Open(ctx, store.Options{
|
||||
Path: filepath.Join(t.TempDir(), "dst.db"),
|
||||
Schema: `
|
||||
create table messages(id text primary key, guild_id text not null, body text not null);
|
||||
@ -69,7 +69,7 @@ create table sync_state(source_name text, entity_type text, entity_id text, valu
|
||||
|
||||
func TestExportRotatesShards(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
src, err := sqlitekit.Open(ctx, sqlitekit.Options{
|
||||
src, err := store.Open(ctx, store.Options{
|
||||
Path: filepath.Join(t.TempDir(), "src.db"),
|
||||
Schema: `create table things(id integer primary key, value text not null);`,
|
||||
})
|
||||
@ -96,7 +96,7 @@ func TestExportRotatesShards(t *testing.T) {
|
||||
|
||||
func TestImportHooks(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
src, err := sqlitekit.Open(ctx, sqlitekit.Options{
|
||||
src, err := store.Open(ctx, store.Options{
|
||||
Path: filepath.Join(t.TempDir(), "src.db"),
|
||||
Schema: `create table things(id text primary key, keep integer not null);`,
|
||||
})
|
||||
@ -110,7 +110,7 @@ func TestImportHooks(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
dst, err := sqlitekit.Open(ctx, sqlitekit.Options{
|
||||
dst, err := store.Open(ctx, store.Options{
|
||||
Path: filepath.Join(t.TempDir(), "dst.db"),
|
||||
Schema: `create table things(id text primary key, keep integer not null); create table audit(event text not null);`,
|
||||
})
|
||||
@ -127,7 +127,7 @@ func TestImportHooks(t *testing.T) {
|
||||
return err
|
||||
},
|
||||
DeleteTable: func(ctx context.Context, tx *sql.Tx, table string) error {
|
||||
_, err := tx.ExecContext(ctx, `delete from `+sqlitekit.QuoteIdent(table)+` where keep != 0`)
|
||||
_, err := tx.ExecContext(ctx, `delete from `+store.QuoteIdent(table)+` where keep != 0`)
|
||||
return err
|
||||
},
|
||||
}); err != nil {
|
||||
@ -1,4 +1,4 @@
|
||||
package syncstate
|
||||
package state
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -1,4 +1,4 @@
|
||||
package syncstate
|
||||
package state
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -1,4 +1,4 @@
|
||||
package sqlitekit
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -1,4 +1,4 @@
|
||||
package sqlitekit
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -1,4 +1,4 @@
|
||||
package termkit
|
||||
package tui
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -1,4 +1,4 @@
|
||||
package termkit
|
||||
package tui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
Loading…
Reference in New Issue
Block a user