Skip to content

Clean up *.tmp files

Dmitry Gruzd requested to merge 7-cleanup-tmp-files into main

This MR introduces a gorutine that is executed every 5 minutes and deletes *.tmp files if there is no in-progress indexing. In this MR I've also added an error if you try to index the same repository concurrently.

Closes #7 (closed)

Steps to reproduce the problem

  1. Add a big project in your GDK (you can import gitlab for example)
  2. Execute make watch-run listen=:6061 index_dir=$GDK_DIR/zoekt-data/development/index
  3. Get project path by running "#{project.repository.disk_path}.git"
  4. Add this line to internal/zoekt/zoekt.go to reduce the wait time
diff --git a/internal/zoekt/zoekt.go b/internal/zoekt/zoekt.go
index d124560..a6fb74e 100644
--- a/internal/zoekt/zoekt.go
+++ b/internal/zoekt/zoekt.go
@@ -50,6 +50,7 @@ func defaultBuilderOptions(opts *Options) *build.Options {
 	buildOpts := build.Options{
 		IndexDir: opts.IndexDir,
 		SizeMax:  opts.SizeMax,
+		ShardMax: 1024,
 		RepositoryDescription: zoekt.Repository{
 			ID:       opts.ID,
 			Name:     fmt.Sprint(opts.ID),
  1. Execute curl -XPOST -d '{"GitalyConnectionInfo": {"Address": "unix:/$GDK_DIR/praefect.socket", "Storage": "default", "Path": "<@hashed/....git>"}, "RepoId":23, "FileSizeLimit": 2097152, "Timeout": "5s"}' -H 'Content-Type: application/json' http://127.0.0.1:6061/indexer/index
  2. Ensure that the request has timed out and that you have multiple *.tmp files in $GDK_DIR/zoekt-data/development/index
  3. Wait until the tmp files automatically removed (you can change TmpCleanupTicker if you don't want to waint 5 minutes)
Edited by Dmitry Gruzd

Merge request reports