Skip to content

Commit

Permalink
Merge pull request #101 from Kota-Karthik/revert-74-add-dry-run
Browse files Browse the repository at this point in the history
Revert "Add --dry-run Functionality to TwinTrim for Safe Simulated Duplicate Removal"
  • Loading branch information
Kota-Karthik authored Oct 8, 2024
2 parents b5e7b8c + d52236c commit 4338f28
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ TwinTrim is a powerful and efficient tool designed to find and manage duplicate
- **Multi-Threaded Processing**: Utilizes multi-threading to quickly scan and process large numbers of files concurrently.
- **Deadlock Prevention**: Implements locks to prevent deadlocks during multi-threaded operations, ensuring smooth and safe execution.
- **User-Friendly Interface**: Offers clear prompts and feedback via the command line, making the process straightforward and interactive.
- **Dry Run**: Use the --dry-run option to simulate the process without making any changes, allowing you to review what will happen before executing.

## How It Works

Expand All @@ -33,9 +32,6 @@ TwinTrim is a powerful and efficient tool designed to find and manage duplicate

5. **Deadlock Prevention**:
- Uses locks within multi-threaded processes to ensure that resources are accessed safely, preventing deadlocks that could otherwise halt execution.

6. **Dry Run Mode**:
- The --dry-run flag allows you to simulate the duplicate removal process without making any actual changes, giving you an opportunity to review potential actions before committing to them.

### Key Functions

Expand Down Expand Up @@ -63,7 +59,6 @@ python twinTrim.py <directory> [OPTIONS]
- `--exclude`: Exclude specific files by name.
- `--label-color`: Set the font color of the output label of the progress bar.
- `--bar-color`: Set the color of the progress bar.
- `--dry-run`: Simulate the duplicate removal process without making any changes.

### Examples

Expand Down
26 changes: 2 additions & 24 deletions twinTrim/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
@click.option("--exclude", multiple=True, help="Files to exclude by name.")
@click.option("--label-color", default="yellow", type=str, help="Color of the label of progress bar.")
@click.option("--bar-color", default='#aaaaaa', type=str, help="Color of the progress bar.")
@click.option("--dry-run", is_flag=True, help="Simulate the process without deleting files.")
def cli(directory, all, min_size, max_size, file_type, exclude, label_color, bar_color, dry_run):
def cli(directory, all, min_size, max_size, file_type, exclude, label_color, bar_color):
"""Find and manage duplicate files in the specified DIRECTORY."""

# Initialize the FileFilter object
file_filter = FileFilter()
file_filter.setMinFileSize(parse_size(min_size))
Expand All @@ -37,14 +36,8 @@ def cli(directory, all, min_size, max_size, file_type, exclude, label_color, bar
file_filter.addFileExclude(file_name)

if all:
add-dry-run
if dry_run:
click.echo(click.style("Dry run mode enabled: Skipping actual deletion.", fg='yellow'))
handleAllFlag(directory, file_filter, label_color, bar_color, dry_run=dry_run) # Modify handleAllFlag to support dry_run
=======
logging.info("Deleting all duplicate files whithout asking.")
handleAllFlag(directory, file_filter, label_color, bar_color)
>>>>> main
return

start_time = time.time()
Expand Down Expand Up @@ -90,20 +83,6 @@ def cli(directory, all, min_size, max_size, file_type, exclude, label_color, bar
files_to_delete = [duplicates_list[int(option.split(")")[0]) - 1] for option in selected_indices]

for file_path in files_to_delete:
add-dry-run
if dry_run:
click.echo(click.style(f"[Dry Run] Would delete: {file_path}", fg='yellow'))
else:
handle_and_remove(file_path)

if not dry_run:
click.echo(click.style("Selected duplicate files removed!", fg='green'))
else:
click.echo(click.style("Dry run completed. No files were actually deleted.", fg='yellow'))

click.echo(click.style(f"Time taken: {time_taken:.2f} seconds.", fg='green'))

=======
try:
handle_and_remove(file_path)
logging.info(f"Deleted duplicate file: {file_path}")
Expand All @@ -119,4 +98,3 @@ def cli(directory, all, min_size, max_size, file_type, exclude, label_color, bar

if __name__ == "__main__":
cli()
main

0 comments on commit 4338f28

Please sign in to comment.