-
Notifications
You must be signed in to change notification settings - Fork 0
/
CuMultiThreadHash.js
5338 lines (4770 loc) · 250 KB
/
CuMultiThreadHash.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// @ts-check
/* eslint quotes: ['error', 'single'] */
/* eslint-disable no-inner-declarations */
/* global ActiveXObject Enumerator DOpus Script */
/* eslint indent: [2, 4, {"SwitchCase": 1}] */
///<reference path="./_DOpusDefinitions.d.ts" />
///<reference path="./CuMultiThreadHash.d.ts" />
// JScript cannot include external files and this development has grown very big for 1 file.
// So it must be tamed some other way.
// The big ASCII section titles for VSCodium minimap.
// Nested blocks are used so that I can collapse multiple blocks,
// especially level 4 then with CTRL-K-4 & CTRL-K-2, try it.
/*
.d8888b. 888 .d88888b. 888888b. d8888 888
d88P Y88b 888 d88P" "Y88b 888 "88b d88888 888
888 888 888 888 888 888 .88P d88P888 888
888 888 888 888 8888888K. d88P 888 888
888 88888 888 888 888 888 "Y88b d88P 888 888
888 888 888 888 888 888 888 d88P 888 888
Y88b d88P 888 Y88b. .d88P 888 d88P d8888888888 888
"Y8888P88 88888888 "Y88888P" 8888888P" d88P 888 88888888
*/
{
function Initialize() {
}
{
// the gigantic ASCII figlets are just for VSCode minimap :) - by https://textart.io/figlet
var Global = {};
Global.SCRIPT_NAME = 'CuMultiThreadHash'; // WARNING: if you change this after initial use you have to reconfigure your columns, infotips, rename scripts...
Global.SCRIPT_NAME_SHORT = 'MTH'; // WARNING: if you change this after initial use you have to rename all methods!
Global.SCRIPT_VERSION = '0.9';
Global.SCRIPT_COPYRIGHT = '© 2021 cuneytyilmaz.com';
Global.SCRIPT_URL = 'https://github.com/cy-gh/DOpus_MultiThreadHash/';
Global.SCRIPT_DESC = 'Multi-Threaded hashing of selected files ';
Global.SCRIPT_MIN_VERSION = '12.0';
Global.SCRIPT_DATE = '20210115';
Global.SCRIPT_GROUP = 'cuneytyilmaz.com';
Global.SCRIPT_PREFIX = Global.SCRIPT_NAME_SHORT; // prefix for field checks, log outputs, progress windows, etc. - do not touch
Global.SCRIPT_LICENSE = 'Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)';
Global.SCRIPT_FULLPATH = '';
Global.SCRIPT_PATH = '';
Global.SCRIPT_IS_OSP = false;
/** @type {string} */
var STREAM_PREFIX = 'MTHash_';
// TRUE is highly recommended
// if an error is encountered, it is automatically cleared anyway, to prevent any unexpected side-effects
// so activating it should be safe
/** @type {boolean} */
var CACHE_ENABLED = true;
/**
* @typedef Algorithm
* @type {object}
*
* @property {string} name
* @property {string} fileExt
* @property {boolean} native
* @property {boolean=} viaFilelist
* @property {string=} binaryPath
* @property {number=} maxThreads
*/
/**
* Why are SHA-256 & SHA-512 are missing from this list?
* read the README.MD, short answer: as of this development (v12.23), the DOpus implementations are buggy
* @type {Object.<string, Algorithm>}
*/
/**
* @property {Algorithm} MD5
* @property {Algorithm} SHA1
* @property {Algorithm} BLAKE3
*/
var ALGORITHMS = {
MD5 : { name: 'MD5', fileExt: '.md5', native: true },
SHA1 : { name: 'SHA1', fileExt: '.sha1', native: true },
BLAKE3 : { name: 'BLAKE3', fileExt: '.blake3', native: false, binaryPath: '%gvdTool%\\Util\\hashers\\b3sum.exe', viaFilelist: true, maxThreads: 1 }
};
/** @type {Algorithm} */
var DEFAULT_ALGORITHM = ALGORITHMS.SHA1;
var CURRENT_ALGORITHM = DEFAULT_ALGORITHM.name; // TODO - might be converted to a config parameter or command parameter
// for a small number of files this makes very little, < 3%, difference to overall performance
// for a large number of files, especially small ones, this slows down a lot, e.g. from 100% speed down to 70%!
/** @type {boolean} */
var USE_PROGRESS_BAR = true;
// %NUMBER_OF_PROCESSORS% gives the logical number of processors, i.e. hyperthreaded ones
// for physical core count use:
// > WMIC CPU Get DeviceID,NumberOfCores,NumberOfLogicalProcessors
// DeviceID NumberOfCores NumberOfLogicalProcessors
// CPU0 12 24
/** @type {number} */
// var MAX_AVAILABLE_CORE_COUNT = doh.shell.ExpandEnvironmentStrings('%NUMBER_OF_PROCESSORS%');
// var MAX_AVAILABLE_CORE_COUNT = new ActiveXObject('WScript.shell').ExpandEnvironmentStrings('%NUMBER_OF_PROCESSORS%');
var MAX_AVAILABLE_CORE_COUNT = parseInt(''+DOpus.fsUtil().resolve('%NUMBER_OF_PROCESSORS%'), 10);
// this must be NOT the function name but the COMMAND name!
// we will start it via 'dopusrt /acmd <WORKER_COMMAND>...' to start the threads
/** @type {string} */
var WORKER_COMMAND = 'MTHWorker';
// this command helps us to receive the results from an external call
// instead of creating many external temp files for short outputs,
// we will make the called command set a variable via DOpusRT after it's finished
/** @type {string} */
var WORKER_SETVAR_COMMAND = 'MTHSetVariable';
// collection names for find commands & files which reported an error
/** @type {boolean} */
var COLLECTIONS_ENABLED = true;
/** @type {string} */
var COLL_DUMMY = ''; // needed only used for benchmark action
/** @type {string} */
var COLL_SUCCESS = Global.SCRIPT_NAME_SHORT + ' - ' + 'Verified hashes';
/** @type {string} */
var COLL_DIRTY = Global.SCRIPT_NAME_SHORT + ' - ' + 'Outdated hashes';
/** @type {string} */
var COLL_MISSING = Global.SCRIPT_NAME_SHORT + ' - ' + 'Missing hashes';
/** @type {string} */
var COLL_ERRORS = Global.SCRIPT_NAME_SHORT + ' - ' + 'Files with errors';
/** @type {string} */
var COLL_UPTODATE = Global.SCRIPT_NAME_SHORT + ' - ' + 'Up-to-date hashes';
/** @type {string} */
var COLL_IMPORT_ERRORS = Global.SCRIPT_NAME_SHORT + ' - ' + 'Import errors';
/** @type {string} */
var COLL_VERIFY_MISSING = Global.SCRIPT_NAME_SHORT + ' - ' + 'Verify missing files';
// show a summary dialog after manager actions
/** @type {boolean} */
var SHOW_SUMMARY_DIALOG = false;
// export detailed data as comments (SHA, MD5...) or headers (JSON)
// such as snapshot date in various formats, earliest/latest/smallest/largest file name/date, etc.
/** @type {boolean} */
var EXPORT_EXTENDED_DATA = true;
// show detailed information in DOpus Output for each file after operation
// files with errors will be put into a collection regardless of this setting
/** @type {boolean} */
var DUMP_DETAILED_RESULTS = false;
// do not use both of the following; if you do "latest file datetime" wins
// automatically add current date-time to generated export file names
/** @type {boolean} */
var APPEND_CURRENT_DATETIME_TO_EXPORT_FILES = false;
// automatically add file with the latest date-time to generated export file names
/** @type {boolean} */
var APPEND_LATEST_FILE_DATETIME_TO_EXPORT_FILES = true;
/** @type {boolean} */
var SKIP_SAVE_DIALOG_AND_OVERWRITE = true;
// if Export from ADS is clicked but nothing is selected, use all items in the currently displayed tab
/** @type {boolean} */
var EXPORT_USE_ALL_ITEMS_IF_NOTHING_SELECTED = true;
// if Import into ADS is clicked and a single file is selected, use it as source
/** @type {boolean} */
var IMPORT_USE_SELECTED_FILE_AS_SOURCE = true;
// if Export from ADS is clicked and a single directory/file is selected, use it as target name
/** @type {boolean} */
var IMPORT_USE_SELECTED_ITEM_AS_TARGET = true;
// try to determine disk type where selected files reside, i.e. HDD or SSD
// if you are using no HDDs at all, e.g. on a laptop, no external disks, etc. there is no need to activate this
/** @type {boolean} */
var AUTO_DETECT_DISK_TYPE = false;
// reduce the number of threads automatically when using an HDD
// used only if the above is active
/** @type {number} */
var REDUCE_THREADS_ON_HDD_TO = 1;
// self-explanatory
// var TEMPDIR = '%TEMP%';
// TEMPDIR = (''+doh.shell.ExpandEnvironmentStrings(TEMPDIR));
/** @type {string} */
var TEMPDIR = ''+DOpus.fsUtil().resolve('%TEMP%');
}
}
/*
8888888 888b 888 8888888 88888888888
888 8888b 888 888 888
888 88888b 888 888 888
888 888Y88b 888 888 888
888 888 Y88b888 888 888
888 888 Y88888 888 888
888 888 Y8888 888 888
8888888 888 Y888 8888888 888
*/
{
// called by DOpus
/** @param {DOpusScriptInitData} initData */
// eslint-disable-next-line no-unused-vars
function OnInit(initData) {
initData.name = Global.SCRIPT_NAME;
initData.version = Global.SCRIPT_VERSION;
initData.copyright = Global.SCRIPT_COPYRIGHT;
initData.url = Global.SCRIPT_URL;
initData.desc = Global.SCRIPT_DESC;
initData.min_version = Global.SCRIPT_MIN_VERSION;
initData.group = Global.SCRIPT_GROUP;
initData.log_prefix = Global.SCRIPT_PREFIX;
initData.default_enable = true;
doh.clear();
initData.config.CACHE_ENABLED = CACHE_ENABLED;
initData.config.USE_PROGRESS_BAR = USE_PROGRESS_BAR;
initData.config.MAX_AVAILABLE_CORE_COUNT = MAX_AVAILABLE_CORE_COUNT;
initData.config.COLLECTIONS_ENABLED = COLLECTIONS_ENABLED;
initData.config.COLL_SUCCESS = COLL_SUCCESS;
initData.config.COLL_DIRTY = COLL_DIRTY;
initData.config.COLL_MISSING = COLL_MISSING;
initData.config.COLL_ERRORS = COLL_ERRORS;
initData.config.COLL_UPTODATE = COLL_UPTODATE;
initData.config.COLL_IMPORT_ERRORS = COLL_IMPORT_ERRORS;
initData.config.COLL_VERIFY_MISSING = COLL_VERIFY_MISSING;
initData.config.SHOW_SUMMARY_DIALOG = SHOW_SUMMARY_DIALOG;
initData.config.EXPORT_EXTENDED_DATA = EXPORT_EXTENDED_DATA;
initData.config.DUMP_DETAILED_RESULTS = DUMP_DETAILED_RESULTS;
initData.config.APPEND_CURRENT_DATETIME_TO_EXPORT_FILES = APPEND_CURRENT_DATETIME_TO_EXPORT_FILES;
initData.config.APPEND_LATEST_FILE_DATETIME_TO_EXPORT_FILES = APPEND_LATEST_FILE_DATETIME_TO_EXPORT_FILES;
initData.config.SKIP_SAVE_DIALOG_AND_OVERWRITE = SKIP_SAVE_DIALOG_AND_OVERWRITE;
initData.config.EXPORT_USE_ALL_ITEMS_IF_NOTHING_SELECTED = EXPORT_USE_ALL_ITEMS_IF_NOTHING_SELECTED;
initData.config.IMPORT_USE_SELECTED_FILE_AS_SOURCE = IMPORT_USE_SELECTED_FILE_AS_SOURCE;
initData.config.IMPORT_USE_SELECTED_ITEM_AS_TARGET = IMPORT_USE_SELECTED_ITEM_AS_TARGET;
initData.config.AUTO_DETECT_DISK_TYPE = AUTO_DETECT_DISK_TYPE;
initData.config.REDUCE_THREADS_ON_HDD_TO = REDUCE_THREADS_ON_HDD_TO;
initData.config.TEMPDIR = TEMPDIR;
initData.config_desc = DOpus.create().map(
'CACHE_ENABLED', 'Keep seen files in memory cache, TRUE is highly recommended',
'USE_PROGRESS_BAR', 'For a small number of files this makes very little, < 3%, difference to overall performance, for a large number of files, especially small ones, this slows down a lot, e.g. from 100% speed down to 70%!',
'SHOW_SUMMARY_DIALOG', 'Show a summary dialog after manager actions',
'MAX_AVAILABLE_CORE_COUNT', 'Default: automatically derived from CPU core count\nused primarily for SSD/NVME drives, can be overridden via user command parameter',
'DUMP_DETAILED_RESULTS', 'Show detailed information in DOpus Output for each file after operation\nfiles with errors will be put into a collection regardless of this setting',
'AUTO_DETECT_DISK_TYPE', 'Try to determine disk type where selected files reside, i.e. HDD or SSD\nif you are using no HDDs at all, e.g. on a laptop, no external disks, etc. deactivate this to skip check at every operation',
'REDUCE_THREADS_ON_HDD_TO', 'Reduce the number of threads automatically when using an HDD to reduce disk thrashing\nused only if the disk type detection is active',
'COLLECTIONS_ENABLED', 'Collection names for most commands',
'COLL_SUCCESS', 'Files which have successfully verified or files used in on-the-fly calculation',
'COLL_DIRTY', 'Files which have outdated hash files, i.e. its filesize or modification date has been changed since ADS is attached',
'COLL_MISSING', 'Files with no hash ADS',
'COLL_ERRORS', 'Files with valid hashes which failed the checksum verification',
'COLL_UPTODATE', 'Up-to-date hashes\nNot used at the moment',
'COLL_IMPORT_ERRORS', 'Files for which hash values could not be imported from external file to ADS',
'COLL_VERIFY_MISSING', 'Files which were not found from verification from an external hash file (i.e. ADS is ignored)',
'EXPORT_USE_ALL_ITEMS_IF_NOTHING_SELECTED', 'Export hashes from ADS for all files in current lister, if no file or folder is selected',
'IMPORT_USE_SELECTED_FILE_AS_SOURCE', 'Use the selected file as source for importing from external checksum file to ADS',
'IMPORT_USE_SELECTED_ITEM_AS_TARGET', 'Use the selected file as target for exporting from ADS to external checksum file',
'EXPORT_EXTENDED_DATA', 'Include extended data (in header area) in exported checksum files',
'APPEND_CURRENT_DATETIME_TO_EXPORT_FILES', 'Append the current date-time in sort-friendly format YYYYMMDD-HHMMSS',
'APPEND_LATEST_FILE_DATETIME_TO_EXPORT_FILES', 'Append the date-time of file with most recent change in sort-friendly format YYYYMMDD-HHMMSS',
'SKIP_SAVE_DIALOG_AND_OVERWRITE', 'WARNING: Automatically overwrite file if an export is started and a file is selected',
'TEMPDIR', 'Temp directory, derived from %TEMP% envvar'
);
initData.config_groups = DOpus.create().map(
'CACHE_ENABLED', 'Main Options',
'USE_PROGRESS_BAR', 'Main Options',
'SHOW_SUMMARY_DIALOG', 'Main Options',
'MAX_AVAILABLE_CORE_COUNT', 'Main Options',
'DUMP_DETAILED_RESULTS', 'Main Options',
'AUTO_DETECT_DISK_TYPE', 'HDD Detection',
'REDUCE_THREADS_ON_HDD_TO', 'HDD Detection',
'COLLECTIONS_ENABLED', 'Action Output',
'COLL_SUCCESS', 'Action Output',
'COLL_DIRTY', 'Action Output',
'COLL_MISSING', 'Action Output',
'COLL_ERRORS', 'Action Output',
'COLL_UPTODATE', 'Action Output',
'COLL_IMPORT_ERRORS', 'Action Output',
'COLL_VERIFY_MISSING', 'Action Output',
'EXPORT_USE_ALL_ITEMS_IF_NOTHING_SELECTED', 'Import/Export',
'IMPORT_USE_SELECTED_FILE_AS_SOURCE', 'Import/Export',
'IMPORT_USE_SELECTED_ITEM_AS_TARGET', 'Import/Export',
'EXPORT_EXTENDED_DATA', 'Import/Export',
'APPEND_CURRENT_DATETIME_TO_EXPORT_FILES', 'Import/Export',
'APPEND_LATEST_FILE_DATETIME_TO_EXPORT_FILES', 'Import/Export',
'SKIP_SAVE_DIALOG_AND_OVERWRITE', 'Import/Export',
'TEMPDIR', 'Miscellaneous'
);
// put the script path, etc. into DOpus Global Vars,
// Unfortunately initData cannot be accessed later by methods
// even if they are put into Script.Vars, because they get cleared once the script is unloaded from memory
// so the only safe location is not Script.Vars but DOpus.Vars
_setScriptPathVars(initData);
playSoundSuccess();
_initializeCommands(initData);
_initializeColumns(initData);
return false;
}
/**
* Sets a global variable in the global DOpus memory with the fullpath of this script
* so that we can determine if we are in development or released OSP mode
* @param {object} initData DOpus InitData
*/
function _setScriptPathVars(initData) {
var oItem = doh.fsu.getItem(initData.file);
doh.setGlobalVar('Global.SCRIPT_ITEM', oItem);
}
/**
* Reads the fullpath, path name and isOSP flag of this script
* @returns {{fullpath: string, path: string, isOSP: boolean}}
*/
function _getScriptPathVars() {
var oThisScriptsPath = doh.getGlobalVar('Global.SCRIPT_ITEM');
return {
fullpath: ''+oThisScriptsPath.realpath,
path : (''+oThisScriptsPath.path).normalizeTrailingBackslashes(),
// isOSP : (''+doh.fsu.Resolve(oItem.realpath).ext).toLowerCase() === '.osp'
isOSP : (''+oThisScriptsPath.ext).toLowerCase() === '.osp'
};
}
/**
* internal method called by OnInit() directly or indirectly
* @param {string} name column name
*/
function _getColumnLabelFor(name) {
// return Global.SCRIPT_NAME_SHORT + ' ' + name;
return '#' + name;
}
/**
* internal method called by OnInit() directly or indirectly
* @param {string} name column name
*/
function _getColumnNameFor(name) {
return Global.SCRIPT_NAME_SHORT + '_' + name;
}
/**
* internal method called by OnInit() directly or indirectly
* helper method to get the Icon Name for development and OSP version
* @param {string} iconName internal name, the prefix and path will be automatically added
*/
function _getIcon(iconName) {
var myInfo = _getScriptPathVars();
// #MTHasher is defined in the Icons.XML file
return ( myInfo.isOSP ? ('#MTHasher:' + iconName) : (myInfo.path + 'Icons\\MTH_32_' + iconName + '.png') );
}
/**
* internal method called by OnInit() directly or indirectly
* @param {string} name command name, prefix will be added automatically
* @param {function} fnFunction function which implements the command
* @param {DOpusScriptInitData} initData DOpus InitData
* @param {string} template command template, e.g. FILE/O...
* @param {string} icon icon name, internal
* @param {string} label command label
* @param {string} desc command description
* @param {boolean=} hide if true, command is hidden from commands list
*/
function _addCommand(name, fnFunction, initData, template, icon, label, desc, hide) {
var cmd = initData.addCommand();
cmd.name = Global.SCRIPT_NAME_SHORT + name;
cmd.method = funcNameExtractor(fnFunction);
cmd.template = template || '';
cmd.icon = icon && _getIcon(icon) || '';
cmd.label = label || '';
cmd.desc = desc || label;
cmd.hide = typeof hide !== 'undefined' && hide || false;
}
/**
* internal method called by OnInit() directly or indirectly
* @param {string} name column name
* @param {function} fnFunction functhi which implements the column
* @param {object} initData DOpus InitData
* @param {string} label column label
* @param {string} justify left, right, etc.
* @param {boolean} autogroup if values should be grouped by DOpus
* @param {boolean} autorefresh
* @param {boolean} multicol
*/
function _addColumn(name, fnFunction, initData, label, justify, autogroup, autorefresh, multicol) {
var col = initData.AddColumn();
col.method = funcNameExtractor(fnFunction);
col.name = _getColumnNameFor(name);
col.label = _getColumnLabelFor(label || name);
col.justify = justify;
col.autogroup = autogroup;
col.autorefresh = autorefresh;
col.multicol = multicol;
}
/**
* internal method called by OnInit() directly or indirectly
* @param {DOpusScriptInitData} initData DOpus InitData
*/
function _initializeCommands(initData) {
/*
Available icon names, used by GetIcon()
Add
Attach
CopyToClipboard
Delete
FileExport-Download
FileExport-Download2
FileImport-Upload
FileImport-Upload2
FileImportExport
FindDirty
FindDirty2
FindMissing
GitHub
Homepage
QueryInfo
RefreshUpdate
Settings
Sync1
Sync2
Unarchive
Verify
Warning
*/
// function addCommand(initData, name, method, template, icon, label, desc, hide)
_addCommand('ManagerStart',
onDOpusCmdMTHManagerStart,
initData,
'MAXCOUNT/N,' +
'CALCULATE_ONLY/S,HARD_UPDATE_ADS/S,SMART_UPDATE_ADS/S,VERIFY_FROM_ADS/S,DELETE_ADS/S,' +
'FIND_DIRTY/S,FIND_MISSING/S,' +
'VERIFY_FROM/S,FILE/O,' +
'BENCHMARK/S,BENCHMARK_SIZE/O,BENCHMARK_COUNT/O,NO_PROGRESS_BAR/S',
'Green_SmartUpdate',
'MTH Manager',
'Calculates hashes of selected objects and performs an action.\nObjects can be files and folders\nUse one of the parameters to specify action.'
);
_addCommand('Worker',
onDOpusCmdMTHWorker,
initData,
'THREADID/K,ACTIONFUNC/K,VIAFILELIST/S',
'StatusDirty',
'MTH Worker (do not call directly!)',
null,
true // hide from script commands list
);
_addCommand('SetVariable',
onDOpusCmdMTHSetVariable,
initData,
'VARKEY/K,VARVAL/K',
'StatusDirty',
'MTH Worker Helper (do not call directly!)',
null,
true // hide from script commands list
);
_addCommand('ClearCache',
onDOpusCmdMHTClearCache,
initData,
'',
'Red_ClearCache',
'MTH Clear Cache',
'Clears internal cache'
);
_addCommand('DeleteADS',
onDOpusCmdMHTDeleteADS,
initData,
'',
'Red_DeleteADS',
'MTH Delete ADS',
'Deletes stored ADS'
);
_addCommand('CopyToClipboard',
onDOpusCopyToClipboard,
initData,
'SKIP_PRECHECK/S',
'Orange_CopyFromADSToClipboard',
'MTH Copy ADS to Clipboard',
'Copy stored ADS hashes of selected objects to clipboard'
);
_addCommand('ADSExportFrom',
onDOpusADSExportFrom,
initData,
'SKIP_PRECHECK/S,USE_FORWARD_SLASH/S,FILE/O',
'Orange_ExportFromADS',
'MTH Export from ADS',
'Exports stored ADS hashes of selected objects to a file; if filename is supplied and file exists it will be overwritten'
);
_addCommand('ADSImportInto',
onDOpusADSImportInto,
initData,
'FILE/O',
'Orange_ImportIntoADS',
'MTH Import into ADS',
'Imports hashes from selected file to ADS for all matched files by name; the current lister tab path is used to resolve relative paths'
);
}
/**
* internal method called by OnInit() directly or indirectly
* @param {object} initData DOpus InitData
*/
function _initializeColumns(initData) {
// this column is kept separate, no multicol
_addColumn('HasHashStream',
onDOpusColHasStream,
initData,
'Available',
'right', false, true, false);
// all multicol below
_addColumn('NeedsUpdate',
onDOpusColMultiCol,
initData,
'Dirty (Simple)',
'right', false, true, true);
_addColumn('NeedsUpdateVerbose',
onDOpusColMultiCol,
initData,
'Dirty',
'right', false, true, true);
_addColumn('ADSDataFormatted',
onDOpusColMultiCol,
initData,
'ADSData (Formatted)',
'left', true, true, true);
_addColumn('ADSDataRaw',
onDOpusColMultiCol,
initData,
'ADSData (Raw)',
'left', true, true, true);
}
}
/*
.d8888b. .d88888b. 888b d888 888b d888 d8888 888b 888 8888888b. .d8888b.
d88P Y88b d88P" "Y88b 8888b d8888 8888b d8888 d88888 8888b 888 888 "Y88b d88P Y88b
888 888 888 888 88888b.d88888 88888b.d88888 d88P888 88888b 888 888 888 Y88b.
888 888 888 888Y88888P888 888Y88888P888 d88P 888 888Y88b 888 888 888 "Y888b.
888 888 888 888 Y888P 888 888 Y888P 888 d88P 888 888 Y88b888 888 888 "Y88b.
888 888 888 888 888 Y8P 888 888 Y8P 888 d88P 888 888 Y88888 888 888 "888
Y88b d88P Y88b. .d88P 888 " 888 888 " 888 d8888888888 888 Y8888 888 .d88P Y88b d88P
"Y8888P" "Y88888P" 888 888 888 888 d88P 888 888 Y888 8888888P" "Y8888P"
*/
{
// CLEAR CACHE
/** @returns void */
function onDOpusCmdMHTClearCache() {
memory.clearCache();
playSoundSuccess();
}
/** @param {DOpusScriptCommandData} cmdData DOpus command data */
function onDOpusCmdMHTDeleteADS(cmdData) {
var fnName = funcNameExtractor(arguments.callee);
var fnFilter = filters.PUBLIC.fnAcceptWithHashes;
var busyIndicator = new BusyIndicator(cmdData.func.sourceTab, sprintf('%s -- Filter: %s', fnName, fnFilter)).start();
var selectedFiltered = applyFilterToSelectedItems(doh.getSelItems(cmdData), fnFilter);
var oItems = selectedFiltered.getSuccessItems();
if (!oItems) {
playSoundError();
} else {
var oDOpusItemCollection = new DOpusItemsVector();
for (var filepath in oItems) {
oDOpusItemCollection.addItem(doh.fsu.getItem(filepath));
}
ADS.remove(oDOpusItemCollection);
playSoundSuccess();
}
busyIndicator.stop();
}
/** @param {DOpusScriptCommandData} cmdData DOpus command data */
function onDOpusCopyToClipboard(cmdData) {
var resHashes = _getHashesOfAllSelectedFiles(cmdData, CURRENT_ALGORITHM);
if (resHashes.isErr()) {
// a message dialog is automatically shown in _getHashesOfAllSelectedFiles()
playSoundForResult(resHashes);
return;
}
doh.cmd.runCommand('Clipboard SET ' + JSON.stringify(resHashes.ok, null, 4));
playSoundSuccess();
}
/** @param {DOpusScriptCommandData} cmdData DOpus command data */
function onDOpusADSExportFrom(cmdData) {
// check command parameters
// var filename = cmdData.func.args.FILE;
var useForwardSlash = cmdData.func.args.got_arg.USE_FORWARD_SLASH;
var resFilename = _getFileName(cmdData, false);
if (resFilename.isErr()) {
playSoundForResult(resFilename);
return showMessageDialog(cmdData.func.dlg(), 'Cannot continue without a valid file/path', 'Invalid path');
}
// get the hashes
var resHashes = _getHashesOfAllSelectedFiles(cmdData, CURRENT_ALGORITHM);
if (resHashes.isErr()) {
playSoundForResult(resHashes);
return; // a message dialog is automatically shown in _getHashesOfAllSelectedFiles()
}
// save the file
var resExport = fileImportExport.exportTo(cmdData, resHashes.ok, useForwardSlash);
playSoundForResult(resExport);
if (resExport.isErr()) {
return showMessageDialog(cmdData.func.dlg(), 'File could not be saved:\n' + resExport.err, 'Save error' );
}
}
/** @param {DOpusScriptCommandData} cmdData DOpus command data */
function onDOpusADSImportInto(cmdData) {
var resFilename = _getFileName(cmdData);
if (resFilename.isErr()) {
playSoundForResult(resFilename);
return showMessageDialog(cmdData.func.dlg(), 'Cannot continue without a valid file/path', 'Invalid path');
}
var resImport = fileImportExport.importFrom(cmdData);
playSoundForResult(resImport);
}
/**
* @param {DOpusScriptCommandData} cmdData DOpus command data
* @param {boolean} [forOpen=true] true if file is meant for saving, i.e. does not need to exist before the action
* @param {string=} suggestedNameSuffix for saving files
* @return {Result.<{name: string, format: string}, boolean>} filename & format on success
*/
function _getFileName(cmdData, forOpen, suggestedNameSuffix) {
var fnName = funcNameExtractor(arguments.callee);
var file = cmdData.func.args.got_arg.FILE ? cmdData.func.args.FILE : '';
forOpen = typeof forOpen === 'undefined' ? true : !!forOpen;
var currentPath = doh.getCurrentPath(cmdData),
filename = '',
basename = '',
detectedFormat,
oPath;
/**
* @param {string} filename
* @returns {Result.<string, string>} format on success, given file's extension if unsupported
*/
function detectFormatFromName(filename) {
var oItem = doh.fsu.getItem(filename);
switch(oItem.ext.toLowerCase()) {
case ALGORITHMS.MD5.fileExt: return ResultOk(ALGORITHMS.MD5.name);
case ALGORITHMS.SHA1.fileExt: return ResultOk(ALGORITHMS.SHA1.name);
case ALGORITHMS.BLAKE3.fileExt: return ResultOk(ALGORITHMS.BLAKE3.name);
default: return ResultErr(oItem.ext);
}
}
if (typeof file === 'string' && file) {
// validate given filename
if(forOpen) {
if(!FS.isValidPath(file)) {
if (!FS.isValidPath(currentPath + file)) {
return ResultErr(sprintf('%s -- Given path %s is invalid', fnName, file));
} else {
filename = currentPath + file;
}
} else {
filename = file;
}
} else {
if (!FS.isValidPath(''+doh.fsu.getItem(file).path)) {
if (!FS.isValidPath(''+doh.fsu.getItem(currentPath + file).path)) {
return ResultErr(sprintf('%s -- Given path %s cannot be used (missing parent folders are not automatically created)', fnName, file));
}
else {
filename = currentPath + file;
}
} else {
filename = file;
}
}
} else if (forOpen) {
if (Script.config.IMPORT_USE_SELECTED_FILE_AS_SOURCE && doh.getSelItemsCount(cmdData) === 1 && doh.getSelFilesCount(cmdData) === 1) {
// if a single file is selected use it as source
filename = ''+doh.getSelFileAsItem(cmdData).realpath;
logger.sverbose('%s -- Using selected file as input: %s', fnName, filename);
}
detectedFormat = detectFormatFromName(filename);
if (detectedFormat.isErr()) {
// show an Open Dialog
oPath = cmdData.func.dlg().open('Open', currentPath);
if (oPath.result) filename = ''+oPath;
}
} else {
if (Script.config.IMPORT_USE_SELECTED_ITEM_AS_TARGET && doh.getSelItemsCount(cmdData) === 1 && doh.getSelDirsCount(cmdData) === 1) {
// if a single directory is selected use it as target name
basename = ''+doh.getSelectedAsItem(cmdData).name_stem;
logger.sverbose('%s -- Using selected item name in output: %s', fnName, basename);
} else {
// if no or multiple items are selected use the current path as base name
basename = (''+currentPath).replace(/[\\:]/g, '_').replace(/_*$/, '').replace(/_+/, '_') + (cmdData.func.args.got_arg.USE_FORWARD_SLASH ? '_FS' : '');
logger.sverbose('%s -- Using current directory name in output: %s', fnName, basename);
}
suggestedNameSuffix = suggestedNameSuffix ? ' - ' + suggestedNameSuffix : '';
filename = currentPath + basename + suggestedNameSuffix + ALGORITHMS[CURRENT_ALGORITHM].fileExt;
logger.sverbose('%s -- Using filename for output: %s', fnName, filename);
if (!Script.config.SKIP_SAVE_DIALOG_AND_OVERWRITE) {
// show a Save Dialog
oPath = cmdData.func.dlg().save('Save', filename);
if (!oPath.result) abortWith(new UserAbortedException('User aborted', fnName));
filename = ''+oPath;
}
}
// check if file can be used
if (filename) {
detectedFormat = detectFormatFromName(filename);
if (detectedFormat.isErr()) {
return ResultErr(sprintf('%s -- Given file %s cannot be used, unsupported format/extension', fnName, file));
}
}
return filename ? ResultOk({name: filename, format: detectedFormat.ok}) : ResultErr(true);
}
}
/*
.d8888b. .d88888b. 888 888 888 888b d888 888b 888 .d8888b.
d88P Y88b d88P" "Y88b 888 888 888 8888b d8888 8888b 888 d88P Y88b
888 888 888 888 888 888 888 88888b.d88888 88888b 888 Y88b.
888 888 888 888 888 888 888Y88888P888 888Y88b 888 "Y888b.
888 888 888 888 888 888 888 Y888P 888 888 Y88b888 "Y88b.
888 888 888 888 888 888 888 888 Y8P 888 888 Y88888 "888
Y88b d88P Y88b. .d88P 888 Y88b. .d88P 888 " 888 888 Y8888 Y88b d88P
"Y8888P" "Y88888P" 88888888 "Y88888P" 888 888 888 Y888 "Y8888P"
*/
{
/**
* @param {DOpusScriptColumnData} scriptColData
*/
function onDOpusColHasStream(scriptColData){
var item = scriptColData.item;
if (!doh.isValidDOItem(item) || !doh.isFile(item) || !FS.isValidPath(''+item.realpath)) return;
var res = ADS.hasHashStream(item);
scriptColData.value = res ? 'Yes' : 'No';
scriptColData.group = 'Has Metadata: ' + scriptColData.value;
}
/**
* @param {DOpusScriptColumnData} scriptColData
*/
function onDOpusColMultiCol(scriptColData) {
var item = scriptColData.item;
if (!doh.isFile(item)) return;
// get ADS object
var res = ADS.read(item);
if (res.isErr()) {
logger.verbose(item.name + ': Metadata does not exist or INVALID: ' + res.err);
return;
}
var itemProps = res.ok;
// iterate over requested columns
for (var e = new Enumerator(scriptColData.columns); !e.atEnd(); e.moveNext()) {
var key = e.item();
var outstr, differentModifDate, differentSize;
switch(key) {
case _getColumnNameFor('NeedsUpdate'):
differentModifDate = new Date(item.modify).valueOf() !== itemProps.last_modify;
differentSize = parseInt(''+item.size, 10) !== itemProps.last_size;
outstr = differentModifDate || differentSize ? 'Yes' : 'No';
scriptColData.columns.get(key).group = 'Needs update: ' + (outstr ? 'Yes' : 'No');
scriptColData.columns.get(key).value = outstr;
break;
case _getColumnNameFor('NeedsUpdateVerbose'):
differentModifDate = new Date(item.modify).valueOf() !== itemProps.last_modify;
differentSize = parseInt(''+item.size, 10) !== itemProps.last_size;
outstr = differentModifDate || differentSize ? 'Yes' : 'No';
if (differentModifDate && differentSize) {
outstr += ' (date & size)';
} else if (differentModifDate) {
outstr += ' (date)';
} else if (differentSize) {
outstr += ' (size)';
}
scriptColData.columns.get(key).group = 'Needs update (Verbose): ' + (outstr ? 'Yes' : 'No');
scriptColData.columns.get(key).value = outstr;
break;
case _getColumnNameFor('ADSDataRaw'):
scriptColData.columns.get(key).value = JSON.stringify(itemProps);
break;
case _getColumnNameFor('ADSDataFormatted'):
scriptColData.columns.get(key).value = JSON.stringify(itemProps, null, '\t');
break;
} // switch
} // for enum
}
}
/*
888b d888 d8888 888b 888 d8888 .d8888b. 8888888888 8888888b.
8888b d8888 d88888 8888b 888 d88888 d88P Y88b 888 888 Y88b
88888b.d88888 d88P888 88888b 888 d88P888 888 888 888 888 888
888Y88888P888 d88P 888 888Y88b 888 d88P 888 888 8888888 888 d88P
888 Y888P 888 d88P 888 888 Y88b888 d88P 888 888 88888 888 8888888P"
888 Y8P 888 d88P 888 888 Y88888 d88P 888 888 888 888 888 T88b
888 " 888 d8888888888 888 Y8888 d8888888888 Y88b d88P 888 888 T88b
888 888 d88P 888 888 Y888 d88P 888 "Y8888P88 8888888888 888 T88b
*/
{
// called by custom DOpus command
/**
*
* @param {DOpusScriptCommandData} cmdData DOpus command data
* @throws @see {InvalidFormatException}
* @throws @see {InvalidManagerCommandException}
*/
function onDOpusCmdMTHManagerStart(cmdData) {
var fnName = funcNameExtractor(arguments.callee);
doh.clear();
logger.sforce('%s -- Global.SCRIPT_DESC: %s', fnName, Global.SCRIPT_DESC);
// VALIDATE PARAMETERS & SET FILTERS, ACTIONS AND COLLECTIONS
{
/**
* @typedef SWITCH
* @type {object}
* @property {string} name
* @property {function} filter
* @property {function} action
* @property {string} collSuccess
* @property {string=} collErrors
* @property {string=} collSkipped
* @property {number=} maxCount
*/
/**
* @type {Object.<string, SWITCH>}
*/
var VALID_SWITCHES = {
CALCULATE_ONLY : { name: 'CALCULATE_ONLY', filter: filters.PUBLIC.fnAcceptAnyFile, action: actions.PUBLIC.fnCalculateOnly, collSuccess: Script.config.COLL_SUCCESS, collErrors: Script.config.COLL_ERRORS },
HARD_UPDATE_ADS : { name: 'HARD_UPDATE_ADS', filter: filters.PUBLIC.fnAcceptAnyFile, action: actions.PUBLIC.fnCalculateAndSaveToADS, collSuccess: Script.config.COLL_SUCCESS, collErrors: Script.config.COLL_ERRORS },
SMART_UPDATE_ADS : { name: 'SMART_UPDATE_ADS', filter: filters.PUBLIC.fnAcceptMissingOrDirty, action: actions.PUBLIC.fnCalculateAndSaveToADS, collSuccess: Script.config.COLL_SUCCESS, collErrors: Script.config.COLL_ERRORS, collSkipped: Script.config.COLL_UPTODATE },
VERIFY_FROM_ADS : { name: 'VERIFY_FROM_ADS', filter: filters.PUBLIC.fnAcceptUptodateOnly, action: actions.PUBLIC.fnCalculateAndCompareToADS, collSuccess: Script.config.COLL_SUCCESS, collErrors: Script.config.COLL_ERRORS, collSkipped: Script.config.COLL_UPTODATE },
DELETE_ADS : { name: 'DELETE_ADS', filter: filters.PUBLIC.fnAcceptWithHashes, action: actions.PUBLIC.fnDeleteADS, collSuccess: Script.config.COLL_SUCCESS, collErrors: Script.config.COLL_ERRORS, collSkipped: Script.config.COLL_UPTODATE, maxCount: 1 },
FIND_DIRTY : { name: 'FIND_DIRTY', filter: filters.PUBLIC.fnAcceptDirtyOnly, action: actions.PUBLIC.fnNull, collSuccess: Script.config.COLL_DIRTY },
FIND_MISSING : { name: 'FIND_MISSING', filter: filters.PUBLIC.fnRejectWithHashes, action: actions.PUBLIC.fnNull, collSuccess: Script.config.COLL_MISSING },
COPY_TO_CLIPBOARD: { name: 'COPY_TO_CLIPBOARD', filter: filters.PUBLIC.fnRejectAnyFile, action: actions.PUBLIC.fnNOT_IMPLEMENTED_YET, collSuccess: COLL_DUMMY },
VERIFY_FROM : { name: 'VERIFY_FROM', filter: filters.PUBLIC.fnAcceptAnyFile, action: actions.PUBLIC.fnCompareAgainstHash, collSuccess: Script.config.COLL_SUCCESS, collErrors: Script.config.COLL_ERRORS, collSkipped: Script.config.COLL_VERIFY_MISSING },
BENCHMARK : { name: 'BENCHMARK', filter: filters.PUBLIC.fnAcceptAnyFile, action: actions.PUBLIC.fnBenchmark, collSuccess: COLL_DUMMY }
};
var cargs = cmdData.func.args;
// maxiumum number of threads, default: all available
var maxcount = cargs.got_arg.MAXCOUNT && cargs.MAXCOUNT.toString().asInt() || Script.config.MAX_AVAILABLE_CORE_COUNT;
// file to use for on-the-fly export & verify
var file = cargs.got_arg.FILE && cargs.FILE.toString() || '';
// input size for benchmarking, 2^10: 1 KB, 2^20: 1 MB...
var benchsize = cargs.got_arg.BENCHMARK_SIZE && cargs.BENCHMARK_SIZE.toString().asInt() || Math.pow(2, 16);
// number of benchmarking iterations per algorithm -> this many files of specified size will be created under TEMPDIR
var benchcount= cargs.got_arg.BENCHMARK_COUNT && cargs.BENCHMARK_COUNT.toString().asInt() || 500;
// whether progress bar should be disabled, default false (=progbar enabled)
var noprogbar = cargs.got_arg.NO_PROGRESS_BAR || false;
for (var sw in VALID_SWITCHES) {
if (cargs.got_arg[sw]) {
var oSW = VALID_SWITCHES[sw];
var command = new ManagerCommand(sw, oSW.maxCount || maxcount, oSW.filter, oSW.action, oSW.collSuccess, oSW.collErrors, oSW.collSkipped, '');
if (file) command.fileName = file; // do not add filename unless given
if (benchsize) command.benchSize = benchsize;
if (benchcount) command.benchCount = benchcount;
if (noprogbar) command.noProgressBar = noprogbar;
logger.snormal('%s -- Switch: %s, Command: %s', fnName, sw, command.toString());
}
}
if(!command) abortWith(new InvalidManagerCommandException('No valid command is given', fnName));
var commandName = command.command,
fnFilter = command.filter,
fnFilterName = command.filterName,
fnAction = command.action,
fnActionName = command.actionName;
}
// VARIABLE INITIALIZATIONS
{
// benchmarking, runaway stoppers for while loops, progress bar abort
var tsStart = now(),
itercnt = 0,
// itermax = Math.round(60 * 60 * 1000),
itermax = Math.pow(2, 50),
userAborted = false,
rootPath = doh.getCurrentPath(cmdData),
sendViaFilelist = false;
}
// SELECTION & FILTERING
{
var busyIndicator = new BusyIndicator(cmdData.func.sourceTab, sprintf('%s -- Filter: %s, Action: %s', fnName, fnFilterName, fnActionName)).start();
/** @type {ThreadedItemsCollection} */
var selectedFiltered;
// if (command.command === 'VERIFY_FROM' ) {
if (fnAction === actions.PUBLIC.fnBenchmark) {
hashPerformanceTest(command.benchSize, command.benchCount, command.maxcount);
return;
} else if (fnAction === actions.PUBLIC.fnCompareAgainstHash) {
// get the given file or user-selected file contents in internal format
var extFileAsPOJO = fileImportExport.verifyFrom(cmdData);
if (!extFileAsPOJO.items) {
abortWith(new InvalidFormatException('Nothing to do, parsing results:' + JSON.stringify(extFileAsPOJO, null, 4), fnName));
}
// populate the collection which will replace the typical user-selected files collection, e.g. in next block with applyFilterToSelectedItems()
selectedFiltered = new ThreadedItemsCollection();
// for (var itemPath in extFileAsPOJO.items) {
// if (!extFileAsPOJO.items.hasOwnProperty(itemPath)) continue; // skip prototype functions, etc.
for (var itemPath in getKeys(extFileAsPOJO.items)) {
var item = extFileAsPOJO.items[itemPath];
var oItem = doh.getItem(itemPath);
if (!oItem) { abortWith(new InvalidParameterTypeException('Item is not valid for path: ' + itemPath, fnName)); return; } // return needed for VSCode/TSC
selectedFiltered.addItem(new ThreadedItem(oItem, '', item.hash, extFileAsPOJO.Algorithm));
}
} else {
selectedFiltered = applyFilterToSelectedItems(doh.getSelItems(cmdData), fnFilter);
}
var selectedItemsCount = selectedFiltered.countSuccess;
var selectedItemsSize = selectedFiltered.sizeSuccess;
busyIndicator.stop();
// for Find Dirty & Find Missing we only need to show the selection & filtering results
if (commandName === VALID_SWITCHES.FIND_DIRTY.name || commandName === VALID_SWITCHES.FIND_MISSING.name) {
var collectionName = command.collNameSuccess;
busyIndicator = new BusyIndicator(cmdData.func.sourceTab, sprintf('Populating collection: %s', collectionName)).start();
logger.normal(SW.startAndPrint(fnName, 'Populating collection', 'Collection name: ' + collectionName));
// addFilesToCollection(selectedFiltered.getSuccessItems().keys(), collectionName);
addFilesToCollection(getKeys(selectedFiltered.getSuccessItems()), collectionName);
logger.normal(SW.stopAndPrint(fnName, 'Populating collection'));
busyIndicator.stop();
playSoundSuccess();
return;
}
// if some hashes are missing or dirty, show and quit