@@ -84,72 +84,80 @@ export function compareAsync(rootEntry1: OptionalEntry, rootEntry2: OptionalEntr
84
84
// process entry
85
85
if ( cmp === 0 ) {
86
86
// Both left/right exist and have the same name and type
87
- const permissionDeniedState = Permission . getPermissionDeniedState ( entry1 , entry2 )
87
+ const skipEntry = options . skipSubdirs && type1 === 'directory'
88
+ if ( ! skipEntry ) {
89
+ const permissionDeniedState = Permission . getPermissionDeniedState ( entry1 , entry2 )
88
90
89
- if ( permissionDeniedState === "access-ok" ) {
90
- const compareEntryRes = EntryEquality . isEntryEqualAsync ( entry1 , entry2 , type1 , asyncDiffSet , options )
91
- if ( compareEntryRes . isSync ) {
92
- options . resultBuilder ( entry1 , entry2 ,
93
- compareEntryRes . same ? 'equal' : 'distinct' ,
94
- level , relativePath , options , statistics , asyncDiffSet as DiffSet ,
95
- compareEntryRes . reason , permissionDeniedState )
96
- StatisticsUpdate . updateStatisticsBoth ( entry1 , entry2 , compareEntryRes . same , compareEntryRes . reason ,
97
- type1 , permissionDeniedState , statistics , options )
91
+ if ( permissionDeniedState === "access-ok" ) {
92
+ const compareEntryRes = EntryEquality . isEntryEqualAsync ( entry1 , entry2 , type1 , asyncDiffSet , options )
93
+ if ( compareEntryRes . isSync ) {
94
+ options . resultBuilder ( entry1 , entry2 ,
95
+ compareEntryRes . same ? 'equal' : 'distinct' ,
96
+ level , relativePath , options , statistics , asyncDiffSet as DiffSet ,
97
+ compareEntryRes . reason , permissionDeniedState )
98
+ StatisticsUpdate . updateStatisticsBoth ( entry1 , entry2 , compareEntryRes . same , compareEntryRes . reason ,
99
+ type1 , permissionDeniedState , statistics , options )
100
+ } else {
101
+ fileEqualityAsyncPromises . push ( compareEntryRes . fileEqualityAsyncPromise )
102
+ }
98
103
} else {
99
- fileEqualityAsyncPromises . push ( compareEntryRes . fileEqualityAsyncPromise )
104
+ const state = 'distinct'
105
+ const reason = "permission-denied"
106
+ const same = false
107
+ options . resultBuilder ( entry1 , entry2 , state , level , relativePath , options , statistics , asyncDiffSet as DiffSet , reason , permissionDeniedState )
108
+ StatisticsUpdate . updateStatisticsBoth ( entry1 , entry2 , same , reason , type1 , permissionDeniedState , statistics , options )
109
+ }
110
+ if ( type1 === 'directory' ) {
111
+ const subDiffSet : AsyncDiffSet = [ ]
112
+ if ( ! options . noDiffSet ) {
113
+ asyncDiffSet . push ( subDiffSet )
114
+ }
115
+ const comparePromise = limit ( ( ) => compareAsync ( entry1 , entry2 , level + 1 ,
116
+ pathUtils . join ( relativePath , entry1 . name ) ,
117
+ options , statistics , subDiffSet , LoopDetector . cloneSymlinkCache ( symlinkCache ) ) )
118
+ comparePromises . push ( comparePromise )
100
119
}
101
- } else {
102
- const state = 'distinct'
103
- const reason = "permission-denied"
104
- const same = false
105
- options . resultBuilder ( entry1 , entry2 , state , level , relativePath , options , statistics , asyncDiffSet as DiffSet , reason , permissionDeniedState )
106
- StatisticsUpdate . updateStatisticsBoth ( entry1 , entry2 , same , reason , type1 , permissionDeniedState , statistics , options )
107
120
}
108
-
109
121
i1 ++
110
122
i2 ++
111
- if ( ! options . skipSubdirs && type1 === 'directory' ) {
112
- const subDiffSet : AsyncDiffSet = [ ]
113
- if ( ! options . noDiffSet ) {
114
- asyncDiffSet . push ( subDiffSet )
115
- }
116
- const comparePromise = limit ( ( ) => compareAsync ( entry1 , entry2 , level + 1 ,
117
- pathUtils . join ( relativePath , entry1 . name ) ,
118
- options , statistics , subDiffSet , LoopDetector . cloneSymlinkCache ( symlinkCache ) ) )
119
- comparePromises . push ( comparePromise )
120
- }
121
123
} else if ( cmp < 0 ) {
122
124
// Right missing
123
- const permissionDeniedState = Permission . getPermissionDeniedStateWhenRightMissing ( entry1 )
124
- options . resultBuilder ( entry1 , undefined , 'left' , level , relativePath , options , statistics , asyncDiffSet as DiffSet , undefined , permissionDeniedState )
125
- StatisticsUpdate . updateStatisticsLeft ( entry1 , type1 , permissionDeniedState , statistics , options )
126
- i1 ++
127
- if ( type1 === 'directory' && ! options . skipSubdirs ) {
128
- const subDiffSet : AsyncDiffSet = [ ]
129
- if ( ! options . noDiffSet ) {
130
- asyncDiffSet . push ( subDiffSet )
125
+ const skipEntry = options . skipSubdirs && type1 === 'directory'
126
+ if ( ! skipEntry ) {
127
+ const permissionDeniedState = Permission . getPermissionDeniedStateWhenRightMissing ( entry1 )
128
+ options . resultBuilder ( entry1 , undefined , 'left' , level , relativePath , options , statistics , asyncDiffSet as DiffSet , undefined , permissionDeniedState )
129
+ StatisticsUpdate . updateStatisticsLeft ( entry1 , type1 , permissionDeniedState , statistics , options )
130
+ if ( type1 === 'directory' ) {
131
+ const subDiffSet : AsyncDiffSet = [ ]
132
+ if ( ! options . noDiffSet ) {
133
+ asyncDiffSet . push ( subDiffSet )
134
+ }
135
+ const comparePromise = limit ( ( ) => compareAsync ( entry1 , undefined ,
136
+ level + 1 ,
137
+ pathUtils . join ( relativePath , entry1 . name ) , options , statistics , subDiffSet , LoopDetector . cloneSymlinkCache ( symlinkCache ) ) )
138
+ comparePromises . push ( comparePromise )
131
139
}
132
- const comparePromise = limit ( ( ) => compareAsync ( entry1 , undefined ,
133
- level + 1 ,
134
- pathUtils . join ( relativePath , entry1 . name ) , options , statistics , subDiffSet , LoopDetector . cloneSymlinkCache ( symlinkCache ) ) )
135
- comparePromises . push ( comparePromise )
136
140
}
141
+ i1 ++
137
142
} else {
138
143
// Left missing
139
- const permissionDeniedState = Permission . getPermissionDeniedStateWhenLeftMissing ( entry2 )
140
- options . resultBuilder ( undefined , entry2 , 'right' , level , relativePath , options , statistics , asyncDiffSet as DiffSet , undefined , permissionDeniedState )
141
- StatisticsUpdate . updateStatisticsRight ( entry2 , type2 , permissionDeniedState , statistics , options )
142
- i2 ++
143
- if ( type2 === 'directory' && ! options . skipSubdirs ) {
144
- const subDiffSet : AsyncDiffSet = [ ]
145
- if ( ! options . noDiffSet ) {
146
- asyncDiffSet . push ( subDiffSet )
144
+ const skipEntry = options . skipSubdirs && type2 === 'directory'
145
+ if ( ! skipEntry ) {
146
+ const permissionDeniedState = Permission . getPermissionDeniedStateWhenLeftMissing ( entry2 )
147
+ options . resultBuilder ( undefined , entry2 , 'right' , level , relativePath , options , statistics , asyncDiffSet as DiffSet , undefined , permissionDeniedState )
148
+ StatisticsUpdate . updateStatisticsRight ( entry2 , type2 , permissionDeniedState , statistics , options )
149
+ if ( type2 === 'directory' ) {
150
+ const subDiffSet : AsyncDiffSet = [ ]
151
+ if ( ! options . noDiffSet ) {
152
+ asyncDiffSet . push ( subDiffSet )
153
+ }
154
+ const comparePromise = limit ( ( ) => compareAsync ( undefined , entry2 ,
155
+ level + 1 ,
156
+ pathUtils . join ( relativePath , entry2 . name ) , options , statistics , subDiffSet , LoopDetector . cloneSymlinkCache ( symlinkCache ) ) )
157
+ comparePromises . push ( comparePromise )
147
158
}
148
- const comparePromise = limit ( ( ) => compareAsync ( undefined , entry2 ,
149
- level + 1 ,
150
- pathUtils . join ( relativePath , entry2 . name ) , options , statistics , subDiffSet , LoopDetector . cloneSymlinkCache ( symlinkCache ) ) )
151
- comparePromises . push ( comparePromise )
152
159
}
160
+ i2 ++
153
161
}
154
162
}
155
163
return Promise . all ( comparePromises )
0 commit comments