@@ -146,6 +146,25 @@ security.uploadPackageType = function (directoryPath) {
146146 } ) ;
147147}
148148
149+ // some files are ignored in calc hash in client sdk
150+ // https://github.com/Microsoft/react-native-code-push/pull/974/files#diff-21b650f88429c071b217d46243875987R15
151+ security . isHashIgnored = function ( relativePath ) {
152+ if ( ! relativePath ) {
153+ return true ;
154+ }
155+
156+
157+ const IgnoreMacOSX = '__MACOSX/' ;
158+ const IgnoreDSStore = '.DS_Store' ;
159+ const IgnoreCodePushMetadata = '.codepushrelease' ;
160+
161+ return relativePath . startsWith ( IgnoreMacOSX )
162+ || relativePath === IgnoreDSStore
163+ || relativePath . endsWith ( IgnoreDSStore )
164+ || relativePath === IgnoreCodePushMetadata
165+ || relativePath . endsWith ( IgnoreCodePushMetadata ) ;
166+ }
167+
149168security . calcAllFileSha256 = function ( directoryPath ) {
150169 return new Promise ( ( resolve , reject ) => {
151170 var recursive = require ( "recursive-readdir" ) ;
@@ -156,6 +175,12 @@ security.calcAllFileSha256 = function (directoryPath) {
156175 log . error ( error ) ;
157176 reject ( new AppError . AppError ( error . message ) ) ;
158177 } else {
178+ // filter files that should be ignored
179+ files = files . filter ( ( file ) => {
180+ var relative = path . relative ( directoryPath , file ) ;
181+ return ! security . isHashIgnored ( relative ) ;
182+ } ) ;
183+
159184 if ( files . length == 0 ) {
160185 log . debug ( `calcAllFileSha256 empty files in directoryPath:` , directoryPath ) ;
161186 reject ( new AppError . AppError ( "empty files" ) ) ;
0 commit comments