Skip to content

Commit 8248531

Browse files
committed
feat: index command defaults to ALL drives
Changed behavior: - No --drive/--drives: indexes ALL available NTFS drives - --drive C: indexes only C: - --drives C,D,E: indexes C:, D:, E: The output path now only determines WHERE to save the index, not WHICH drives to index. This matches the search command behavior which also defaults to all drives.
1 parent 717e751 commit 8248531

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/uffs-cli/src/commands.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -652,19 +652,29 @@ pub async fn index(
652652
(Some(drv), None) => vec![drv],
653653
(None, Some(drvs)) => drvs,
654654
(None, None) => {
655-
// Infer drive from output path
655+
// No drives specified - index ALL available NTFS drives
656656
#[cfg(windows)]
657-
let inferred = uffs_mft::infer_drive_from_path(&output);
657+
{
658+
if !uffs_mft::is_elevated() {
659+
anyhow::bail!(
660+
"Administrator privileges required.\n\n\
661+
UFFS reads the NTFS Master File Table directly, which requires elevated access.\n\n\
662+
Solutions:\n\
663+
1. Run PowerShell/Terminal as Administrator\n\
664+
2. Specify a drive explicitly: uffs index --drive C output.parquet"
665+
);
666+
}
667+
let all_drives = uffs_mft::detect_ntfs_drives();
668+
if all_drives.is_empty() {
669+
anyhow::bail!("No NTFS drives found on this system");
670+
}
671+
info!(drives = ?all_drives, count = all_drives.len(), "No drive specified - indexing all NTFS drives");
672+
all_drives
673+
}
658674
#[cfg(not(windows))]
659-
let inferred: Option<char> = None;
660-
661-
if let Some(drive) = inferred {
662-
info!(drive = %drive, "Inferred drive from output path");
663-
vec![drive]
664-
} else {
675+
{
665676
anyhow::bail!(
666-
"Could not infer drive from path '{}'. Use --drive or --drives to specify.",
667-
output.display()
677+
"No drive specified. Use --drive or --drives to specify which drive(s) to index."
668678
);
669679
}
670680
}

crates/uffs-cli/src/main.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -283,30 +283,27 @@ enum Commands {
283283
neg: String,
284284
},
285285

286-
/// Build an index from a drive's MFT
286+
/// Build an index from drive MFT(s)
287287
///
288-
/// The drive to index is inferred from the output path:
289-
/// - `c:\tmp\index.parquet` → indexes drive C:
290-
/// - `index.parquet` → indexes the drive of the current directory
291-
///
292-
/// Use --drive or --drives to override the inferred drive.
288+
/// By default, indexes ALL available NTFS drives. Use --drive or --drives
289+
/// to limit to specific drives.
293290
///
294291
/// If no extension is provided, defaults to `.parquet`.
295292
///
296293
/// Examples:
297-
/// uffs index index.parquet # Index current drive
298-
/// uffs index c:\data\files.parquet # Index C: drive
299-
/// uffs index myindex # Creates myindex.parquet
300-
/// uffs index -d D index.parquet # Override: index D: drive
294+
/// uffs index index.parquet # Index ALL drives
295+
/// uffs index -d C index.parquet # Index only C: drive
296+
/// uffs index --drives C,D,E out.parquet # Index C:, D:, E:
297+
/// uffs index myindex # Creates myindex.parquet
301298
Index {
302299
/// Output file path (extension defaults to .parquet)
303300
output: PathBuf,
304301

305-
/// Drive letter to index (overrides path inference)
302+
/// Drive letter to index (limits to single drive)
306303
#[arg(short, long, conflicts_with = "drives", value_parser = parse_drive_letter)]
307304
drive: Option<char>,
308305

309-
/// Multiple drive letters to index concurrently (e.g., C,D,E)
306+
/// Multiple drive letters to index (e.g., C,D,E)
310307
#[arg(long, value_delimiter = ',', conflicts_with = "drive", value_parser = parse_drive_letter)]
311308
drives: Option<Vec<char>>,
312309
},

0 commit comments

Comments
 (0)