@@ -14,8 +14,12 @@ part 'fdupes_state.dart';
1414class FdupesBloc extends Bloc <FdupesEvent , FdupesState > {
1515 final List <Directory >? initialDirs;
1616 String ? fdupesLocation;
17+ final SharedPreferences sharedPreferences;
1718
18- FdupesBloc ({this .initialDirs}) : super (FdupesStateInitial (initialDirs)) {
19+ FdupesBloc ({
20+ this .initialDirs,
21+ required this .sharedPreferences,
22+ }) : super (FdupesStateInitial (initialDirs)) {
1923 on < FdupesEventCheckFdupesAvailability > (_onCheckFdupesAvailability);
2024 on < FdupesEventSelectFdupesLocation > (_onSelectFdupesLocation);
2125 on < FdupesEventDirsSelected > (_onDirsSelected);
@@ -62,8 +66,8 @@ class FdupesBloc extends Bloc<FdupesEvent, FdupesState> {
6266 return ;
6367 }
6468 add (FdupesEventCheckFdupesAvailability ());
65- }
66- else emit (FdupesStateFdupesNotFound (statusMsg: 'Not a valid fdupes binary.' ));
69+ } else
70+ emit (FdupesStateFdupesNotFound (statusMsg: 'Not a valid fdupes binary.' ));
6771 }
6872
6973 Future <bool > validFdupesLocation (String path) async {
@@ -84,7 +88,16 @@ class FdupesBloc extends Bloc<FdupesEvent, FdupesState> {
8488 if (s is FdupesStateResult ) {
8589 emit (s.copyWith (loading: true ));
8690 }
87- final dupes = await findDupes (event.dirs, emit: emit);
91+ final skipEmpty = sharedPreferences.getBool ('noempty' ) ?? false ;
92+ final useCache = sharedPreferences.getBool ('usecache' ) ?? false ;
93+ final followSymlinks = sharedPreferences.getBool ('followsymlinks' ) ?? false ;
94+ final dupes = await findDupes (
95+ event.dirs,
96+ emit: emit,
97+ skipEmpty: skipEmpty,
98+ useCache: useCache,
99+ followSymlinks: followSymlinks,
100+ );
88101
89102 emit (FdupesStateResult (dirs: event.dirs, dupeGroups: dupes));
90103 }
@@ -156,10 +169,24 @@ class FdupesBloc extends Bloc<FdupesEvent, FdupesState> {
156169 }
157170 }
158171
159- Future <List <List <String >>> findDupes (List <Directory > dirs, {required Emitter <FdupesState > emit}) async {
172+ Future <List <List <String >>> findDupes (
173+ List <Directory > dirs, {
174+ required Emitter <FdupesState > emit,
175+ required bool skipEmpty,
176+ required bool useCache,
177+ required bool followSymlinks,
178+ }) async {
160179 print ("finding dupes in dirs $dirs " );
180+ final args = [
181+ '-r' ,
182+ if (skipEmpty) '--noempty' ,
183+ if (useCache) '--usecache' ,
184+ if (followSymlinks) '--symlinks' ,
185+ ...dirs.map ((d) => d.path),
186+ ];
187+ print ('cmd line: $fdupesLocation $args ' );
188+ Process process = await Process .start (fdupesLocation! , args);
161189 List <List <String >> dupes = [];
162- Process process = await Process .start (fdupesLocation! , ['-r' , ...dirs.map ((d) => d.path)]);
163190 // stdout.addStream(process.stdout);
164191 final regex = RegExp (r'\[(\d+)/(\d+)\]' );
165192 final stderrBC = process.stderr.asBroadcastStream ();
0 commit comments