@@ -186,6 +186,8 @@ def getManifestHash(compilerBinary, commandLine, sourceFile):
186186 @staticmethod
187187 def getIncludesContentHashForFiles (listOfIncludesAbsolute ):
188188 listOfIncludesHashes = [getFileHash (filepath ) for filepath in listOfIncludesAbsolute ]
189+ if None in listOfIncludesHashes :
190+ return None
189191 return ManifestRepository .getIncludesContentHashForHashes (listOfIncludesHashes )
190192
191193 @staticmethod
@@ -425,6 +427,8 @@ def clean(self, stats, maximumSize):
425427
426428 @staticmethod
427429 def getDirectCacheKey (manifestHash , includesContentHash ):
430+ if includesContentHash is None :
431+ return None
428432 # We must take into account manifestHash to avoid
429433 # collisions when different source files use the same
430434 # set of includes.
@@ -685,8 +689,11 @@ def getCompilerHash(compilerBinary):
685689
686690def getFileHash (filePath , additionalData = None ):
687691 hasher = HashAlgorithm ()
688- with open (filePath , 'rb' ) as inFile :
689- hasher .update (inFile .read ())
692+ try :
693+ with open (filePath , 'rb' ) as inFile :
694+ hasher .update (inFile .read ())
695+ except FileNotFoundError :
696+ return None
690697 if additionalData is not None :
691698 # Encoding of this additional data does not really matter
692699 # as long as we keep it fixed, otherwise hashes change.
@@ -1474,7 +1481,10 @@ def processDirect(cache, objectFile, compiler, cmdLine, sourceFile):
14741481 # NOTE: command line options already included in hash for manifest name
14751482 includesContentHash = ManifestRepository .getIncludesContentHashForFiles (
14761483 [expandBasedirPlaceholder (include , baseDir ) for include in manifest .includeFiles ])
1477- cachekey = manifest .includesContentToObjectMap .get (includesContentHash )
1484+ if includesContentHash is None :
1485+ cachekey = None
1486+ else :
1487+ cachekey = manifest .includesContentToObjectMap .get (includesContentHash )
14781488 if cachekey is not None :
14791489 if cache .compilerArtifactsRepository .section (cachekey ).hasEntry (cachekey ):
14801490 return processCacheHit (cache , objectFile , cachekey )
0 commit comments