1 |
|
2 |
|
3 |
|
4 | module.exports = {
|
5 | updateStatisticsBoth(entry1, entry2, same, reason, type, permissionDeniedState, statistics, options) {
|
6 | same ? statistics.equal++ : statistics.distinct++;
|
7 | if (type === 'file') {
|
8 | same ? statistics.equalFiles++ : statistics.distinctFiles++;
|
9 | }
|
10 | else if (type === 'directory') {
|
11 | same ? statistics.equalDirs++ : statistics.distinctDirs++;
|
12 | }
|
13 | else if (type === 'broken-link') {
|
14 | statistics.brokenLinks.distinctBrokenLinks++;
|
15 | }
|
16 | else {
|
17 | throw new Error('Unexpected type ' + type);
|
18 | }
|
19 | const isSymlink1 = entry1 ? entry1.isSymlink : false;
|
20 | const isSymlink2 = entry2 ? entry2.isSymlink : false;
|
21 | const isSymlink = isSymlink1 || isSymlink2;
|
22 | if (options.compareSymlink && isSymlink) {
|
23 | const symlinks = statistics.symlinks;
|
24 | if (reason === 'different-symlink') {
|
25 | symlinks.distinctSymlinks++;
|
26 | }
|
27 | else {
|
28 | symlinks.equalSymlinks++;
|
29 | }
|
30 | }
|
31 | if (permissionDeniedState === "access-error-left") {
|
32 | statistics.permissionDenied.leftPermissionDenied++;
|
33 | }
|
34 | else if (permissionDeniedState === "access-error-right") {
|
35 | statistics.permissionDenied.rightPermissionDenied++;
|
36 | }
|
37 | else if (permissionDeniedState === "access-error-both") {
|
38 | statistics.permissionDenied.distinctPermissionDenied++;
|
39 | }
|
40 | },
|
41 | updateStatisticsLeft(entry1, type, permissionDeniedState, statistics, options) {
|
42 | statistics.left++;
|
43 | if (type === 'file') {
|
44 | statistics.leftFiles++;
|
45 | }
|
46 | else if (type === 'directory') {
|
47 | statistics.leftDirs++;
|
48 | }
|
49 | else if (type === 'broken-link') {
|
50 | statistics.brokenLinks.leftBrokenLinks++;
|
51 | }
|
52 | else {
|
53 | throw new Error('Unexpected type ' + type);
|
54 | }
|
55 | if (options.compareSymlink && entry1.isSymlink) {
|
56 | statistics.symlinks.leftSymlinks++;
|
57 | }
|
58 | if (permissionDeniedState === "access-error-left") {
|
59 | statistics.permissionDenied.leftPermissionDenied++;
|
60 | }
|
61 | },
|
62 | updateStatisticsRight(entry2, type, permissionDeniedState, statistics, options) {
|
63 | statistics.right++;
|
64 | if (type === 'file') {
|
65 | statistics.rightFiles++;
|
66 | }
|
67 | else if (type === 'directory') {
|
68 | statistics.rightDirs++;
|
69 | }
|
70 | else if (type === 'broken-link') {
|
71 | statistics.brokenLinks.rightBrokenLinks++;
|
72 | }
|
73 | else {
|
74 | throw new Error('Unexpected type ' + type);
|
75 | }
|
76 | if (options.compareSymlink && entry2.isSymlink) {
|
77 | statistics.symlinks.rightSymlinks++;
|
78 | }
|
79 | if (permissionDeniedState === "access-error-right") {
|
80 | statistics.permissionDenied.rightPermissionDenied++;
|
81 | }
|
82 | },
|
83 | };
|
84 |
|
\ | No newline at end of file |