From 39b6d3437694a31ee59d781a93912c6d51d876ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Wed, 3 Aug 2022 01:20:17 +0900 Subject: [PATCH] Do not rebuild .c.* files if cache exists --- botanjs/service/jclassresv.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/botanjs/service/jclassresv.py b/botanjs/service/jclassresv.py index d030e38..94bd15b 100644 --- a/botanjs/service/jclassresv.py +++ b/botanjs/service/jclassresv.py @@ -44,7 +44,7 @@ class Resolver: parent = self.parentMap[ elem ] - if parent != None: + if parent is not None: return self.resource( parent ) def locate( self, key ): @@ -190,10 +190,6 @@ class BotanClassResolver: cssGroup.sort( key = lambda x : x[ "src" ] ) cssList.extend( cssGroup ) - for k in cssList: - print( k[ "src" ] ) - - def getCache( self, fileList, cName, mode ): if self.CR == None: return None @@ -208,20 +204,26 @@ class BotanClassResolver: # Compressed file cFile = os.path.join( self.CR, cFHash ) - if self.flagCompress and self.useCache( cFile ): + cCached = self.useCache( cFile ) + + if self.flagCompress and cCached: return self.BotanCache( cFile, cFHash, self.returnDynamic ) - elif self.useCache( oFile ): - self.JWork.saveCache( - oFile - # Content is None to initiate a compression - , None - , mode - , os.path.join( self.R, "externs" ) - ) + if self.useCache( oFile ): + + if not cCached: + self.JWork.saveCache( + oFile + # Content is None to initiate a compression + , None + , mode + , os.path.join( self.R, "externs" ) + ) return self.BotanCache( oFile, oFHash, False ) + return None + def useCache( self, f ): return os.path.exists( f ) @@ -233,7 +235,7 @@ class BotanClassResolver: cacheFile = self.getCache( cList, md5, "js" ) - if cacheFile != None: + if cacheFile is not None: return cacheFile; # The root file @@ -279,7 +281,7 @@ class BotanClassResolver: md5 = [ None ] cacheFile = self.getCache( cList, md5, "css" ) - if cacheFile != None: + if cacheFile is not None: return cacheFile; struct = "/* @ */"