Unify directory trees and preload snapshots
This commit is contained in:
@@ -268,7 +268,7 @@ func (s *Server) repositoryStats(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, 200, s.service.RepositoryStats(ctx))
|
||||
}
|
||||
func (s *Server) snapshotFiles(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 2*time.Minute)
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Minute)
|
||||
defer cancel()
|
||||
items, err := s.service.SnapshotFiles(ctx, r.PathValue("id"), r.PathValue("snapshot"), r.URL.Query().Get("path"))
|
||||
if err != nil {
|
||||
|
||||
@@ -270,14 +270,12 @@ func (r *Runner) List(ctx context.Context, repo model.Repository, snapshot, path
|
||||
}
|
||||
items := []map[string]any{}
|
||||
scanner := bufio.NewScanner(strings.NewReader(string(output)))
|
||||
scanner.Buffer(make([]byte, 0, 64*1024), 2*1024*1024)
|
||||
for scanner.Scan() {
|
||||
var item map[string]any
|
||||
if json.Unmarshal(scanner.Bytes(), &item) == nil && item["struct_type"] == "node" {
|
||||
items = append(items, item)
|
||||
}
|
||||
if len(items) >= 5000 {
|
||||
break
|
||||
}
|
||||
}
|
||||
return items, scanner.Err()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user