Repository navigation
fix(files): preserve discovered folder and file counts when shallow scan is stopped - #185
Merged
NityamPareek merged 1 commit intoSep 22, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a Shallow Scan was stopped during Phase 2 (Drive Discovery), the folder and file counts discovered from libraries scanned prior to the stop were lost on the final dashboard and summary log (showing 0).
Root Cause
In
ShallowFileEstimator.calculate_resource_metrics, whenis_hard_stop_requested()was detected after_scan_document_libraries, the method returned immediately with early-exit phase runtimes, completely bypassingself._finalize_tenant_totals(...).Because
_finalize_tenant_totalswas skipped:metrics["folderCount"]andmetrics["fileCount"]remained at default0, even thoughmetrics["siteMetrics"]had accumulated the discovered counts for scanned libraries.tenantLevelLargeResourceCount,tenantLevelWarningResourceCount, andsiteClassificationwere not populated.ui/files_ui.pyand the summary log line displayed0.Changes
shallow_file_estimator.py):self._finalize_tenant_totals(metrics, processed_count, failed_count)is now always executed after_scan_document_libraries, ensuringfolderCount,fileCount, threshold counts, andsiteClassificationare aggregated from all scanned libraries before handling the hard stop.[Phase 2: Drive Discovery] Stopped after Xsand[Phase 2] Shallow Drive Discovery stopped)._finalize_tenant_totals(metrics, 0, 0)so tenant totals and site classification are cleanly initialized.ui/files_ui.py):execute_migration_scan: Iffile_metrics.get("folderCount")orfile_metrics.get("fileCount")are0or missing butsiteMetricscontains data, defensively fall back to summing fromsiteMetrics.values().show_results_content: Defensively fall back to summing fromdata.get("siteMetrics", {}).values()for theFolder CountandFile Countstat cards (matching the behavior ofTotal Corpus Sizeand other cards).tests/files/shallow_estimator_test.py):test_hard_stop_during_phase_two_preserves_discovered_countsto verify that stopping mid-phase preserves discovered folder and file counts (matching site metrics sums) and populates phase runtimes and site classification.Testing
python3 -m unittest discover -s tests/files -p "shallow_estimator_test.py": all 39 tests passed.