Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion internal/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ func (i *Indexer) run(ctx context.Context, opts Options) (store.ScanSummary, err
summary.MarkMissingMS = time.Since(missingStarted).Milliseconds()
summary.FilesDeleted = deleted
}
resolveStart := time.Now()
if len(missingCandidatePaths) > 0 {
deleted, err := i.store.MarkFilesDeletedBatch(ctx, repo.ID, scanID, missingCandidatePaths)
if err != nil {
Expand All @@ -568,6 +567,15 @@ func (i *Indexer) run(ctx context.Context, opts Options) (store.ScanSummary, err
summary.FilesDeleted += deleted
}

if summary.FilesDeleted > 0 {
if _, err := i.store.PurgeDeletedFileGraphsForScan(ctx, repo.ID, scanID); err != nil {
_ = i.store.CompleteScan(ctx, scanID, summary, started, "failed", err.Error())
return summary, err
}
}

resolveStart := time.Now()

if len(changedPathSet) == 0 {
summary.ResolveMS = 0
summary.ResolveMode = "none"
Expand Down
17 changes: 17 additions & 0 deletions internal/indexer/indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ func main() {
if deletedSummary.FilesDeleted != 1 {
t.Fatalf("FilesDeleted = %d, want 1", deletedSummary.FilesDeleted)
}

stats, err = s.Stats(ctx, repo.ID)
if err != nil {
t.Fatalf("Stats(after delete) error = %v", err)
}
if stats.Files != 0 {
t.Fatalf("stats.Files after delete = %d, want 0", stats.Files)
}
if stats.Symbols != 0 {
t.Fatalf("stats.Symbols after delete = %d, want 0", stats.Symbols)
}
if stats.References != 0 {
t.Fatalf("stats.References after delete = %d, want 0", stats.References)
}
if stats.Edges != 0 {
t.Fatalf("stats.Edges after delete = %d, want 0", stats.Edges)
}
}

func TestIndexSkipsDotAndGeneratedDirectories(t *testing.T) {
Expand Down
Loading
Loading