Signed-off-by: Lewis lewis@tangled.org
appview/state/router.go
appview/state/router.go
This file has not been changed.
eventconsumer/consumer.go
eventconsumer/consumer.go
This file has not been changed.
knotserver/events.go
knotserver/events.go
This file has not been changed.
+19
-30
knotserver/migrate.go
+19
-30
knotserver/migrate.go
···
25
25
oldPath string
26
26
}
27
27
28
-
func scanLegacyRepos(scanPath string, d *db.DB, logger *slog.Logger) []legacyRepo {
29
-
entries, err := os.ReadDir(scanPath)
28
+
func scanLegacyRepos(scanPath string, logger *slog.Logger) []legacyRepo {
29
+
topEntries, err := os.ReadDir(scanPath)
30
30
if err != nil {
31
31
logger.Error("reading scan path", "error", err)
32
32
return nil
33
33
}
34
34
35
-
return collectLegacyEntries(entries, scanPath, d, logger)
36
-
}
37
-
38
-
func collectLegacyEntries(entries []os.DirEntry, scanPath string, d *db.DB, logger *slog.Logger) []legacyRepo {
39
35
var repos []legacyRepo
40
-
for _, entry := range entries {
36
+
for _, entry := range topEntries {
41
37
if !entry.IsDir() || !strings.HasPrefix(entry.Name(), "did:") {
42
38
continue
43
39
}
···
54
50
continue
55
51
}
56
52
57
-
repos = append(repos, collectReposInOwnerDir(subEntries, entry.Name(), ownerPath, d, logger)...)
58
-
}
59
-
return repos
60
-
}
61
-
62
-
func collectReposInOwnerDir(entries []os.DirEntry, ownerDid, ownerPath string, d *db.DB, logger *slog.Logger) []legacyRepo {
63
-
var repos []legacyRepo
64
-
for _, sub := range entries {
65
-
if !sub.IsDir() {
66
-
continue
67
-
}
68
-
69
-
subPath := filepath.Join(ownerPath, sub.Name())
70
-
if _, err := os.Stat(filepath.Join(subPath, "HEAD")); err != nil {
71
-
logger.Warn("skipping non-repo directory", "path", subPath)
72
-
continue
53
+
ownerDid := entry.Name()
54
+
for _, sub := range subEntries {
55
+
if !sub.IsDir() {
56
+
continue
57
+
}
58
+
subPath := filepath.Join(ownerPath, sub.Name())
59
+
if _, statErr := os.Stat(filepath.Join(subPath, "HEAD")); statErr != nil {
60
+
logger.Warn("skipping non-repo directory", "path", subPath)
61
+
continue
62
+
}
63
+
repos = append(repos, legacyRepo{
64
+
ownerDid: ownerDid,
65
+
repoName: sub.Name(),
66
+
oldPath: subPath,
67
+
})
73
68
}
74
-
75
-
repos = append(repos, legacyRepo{
76
-
ownerDid: ownerDid,
77
-
repoName: sub.Name(),
78
-
oldPath: subPath,
79
-
})
80
69
}
81
70
return repos
82
71
}
83
72
84
73
func migrateReposOnStartup(ctx context.Context, c *config.Config, d *db.DB, e *rbac.Enforcer, n *notifier.Notifier, logger *slog.Logger) {
85
-
repos := scanLegacyRepos(c.Repo.ScanPath, d, logger)
74
+
repos := scanLegacyRepos(c.Repo.ScanPath, logger)
86
75
if len(repos) == 0 {
87
76
logger.Info("no legacy repos found, migration complete")
88
77
return
knotserver/server.go
knotserver/server.go
This file has not been changed.
spindle/stream.go
spindle/stream.go
This file has not been changed.
+1
appview/db/db.go
+1
appview/db/db.go
+1
knotserver/db/db.go
+1
knotserver/db/db.go
History
12 rounds
1 comment
oyster.cafe
submitted
#11
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
merge conflicts detected
expand
collapse
expand
collapse
- go.mod:34
- go.sum:339
expand 0 comments
oyster.cafe
submitted
#10
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#9
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
expand 1 comment
oyster.cafe
submitted
#8
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#7
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#6
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#5
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#4
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#3
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#2
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
2/3 failed, 1/3 success
expand
collapse
expand 0 comments
oyster.cafe
submitted
#1
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
expand 0 comments
oyster.cafe
submitted
#0
1 commit
expand
collapse
knotserver: add repo DID migration on startup
Signed-off-by: Lewis <lewis@tangled.org>
appview/state/router.go:65can you absorb this?knotserver/server.go:91I remember you have tested this against knot1's ~4k repos. Is it ok to run on background without progress indicator?