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: 10 additions & 0 deletions src/cli/cli.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,15 @@ export class CliController {
this.config.disableSize = true;
}

if (options.isTrue('disable-age')) {
this.config.disableAge = true;
}

if (options.isTrue('disable-stats')) {
this.config.disableSize = true;
this.config.disableAge = true;
}

if (this.config.jsonStream && this.config.jsonSimple) {
this.logger.error(ERROR_MSG.CANT_USE_BOTH_JSON_OPTIONS);
this.exitWithError();
Expand Down Expand Up @@ -774,6 +783,7 @@ export class CliController {
(nodeFolder) =>
this.scanService.calculateFolderStats(nodeFolder, {
disableSize: this.config.disableSize,
disableAge: this.config.disableAge,
}),
10, // Limit to 10 concurrent stat calculations at a time
),
Expand Down
2 changes: 2 additions & 0 deletions src/cli/interfaces/config.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ export interface IConfig {
jsonStream: boolean;
jsonSimple: boolean;
disableSize: boolean;
disableAge: boolean;
disableStats: boolean;
}
6 changes: 6 additions & 0 deletions src/cli/services/scan.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import os from 'os';
export interface CalculateFolderStatsOptions {
getModificationTimeForSensitiveResults?: boolean;
disableSize?: boolean;
disableAge?: boolean;
}

export class ScanService {
Expand Down Expand Up @@ -85,6 +86,11 @@ export class ScanService {

return size$.pipe(
switchMap(async () => {
if (options.disableAge) {
nodeFolder.modificationTime = 1;
return nodeFolder;
}

if (
nodeFolder.riskAnalysis?.isSensitive &&
!options.getModificationTimeForSensitiveResults
Expand Down
4 changes: 4 additions & 0 deletions src/cli/ui/components/results.ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,10 @@ export class ResultsUi extends HeavyUi implements InteractiveUi {
daysSinceLastModification = '';
}

if (this.config.disableAge) {
daysSinceLastModification = pc.gray(' ...');
}

// Align to right
const alignMargin = 4 - daysSinceLastModification.length;
daysSinceLastModification =
Expand Down
11 changes: 11 additions & 0 deletions src/constants/cli.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ export const OPTIONS: ICliOptions[] = [
'Skip size and age calculation. Useful for faster scanning and deletion when space info is not needed.',
name: 'disable-size',
},
{
arg: ['--disable-age'],
description: 'Skip age (last modification time) calculation.',
name: 'disable-age',
},
{
arg: ['--disable-stats'],
description:
'Skip both size and age calculation. Shortcut for --disable-size --disable-age.',
name: 'disable-stats',
},
{
arg: ['-v', '--version'],
description: 'Show version.',
Expand Down
2 changes: 2 additions & 0 deletions src/constants/main.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const DEFAULT_CONFIG: IConfig = {
jsonStream: false,
jsonSimple: false,
disableSize: false,
disableAge: false,
disableStats: false,
};

export const MARGINS = {
Expand Down
2 changes: 2 additions & 0 deletions tests/cli/services/scan.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ describe('ScanService', () => {
jsonStream: false,
jsonSimple: false,
disableSize: false,
disableAge: false,
disableStats: false,
};

const mockScanFoundFolder: ScanFoundFolder = {
Expand Down
Loading