@@ -227,23 +227,25 @@ def _read_similar_file(self, source, suffix):
227
227
try :
228
228
with open (candidate , "rb" ) as in_file :
229
229
# _LOGGER.info("Found file {0} for {1}.".format(candidate, source))
230
- return in_file .read ()
230
+ return in_file .read (), candidate
231
231
except :
232
232
pass
233
- return None
233
+ return None , None
234
234
235
235
def load_additional_data (self , source ):
236
236
result = {}
237
+ dependent_files = set ()
237
238
238
- attachments = self ._read_similar_file (source , ".attachments.json" )
239
+ attachments , filename = self ._read_similar_file (source , ".attachments.json" )
239
240
if attachments is not None :
240
241
try :
241
242
attachments = json .loads (attachments .decode ('utf-8' ))
242
243
result ['attachments' ] = attachments
244
+ dependent_files .add (filename )
243
245
except Exception as e :
244
246
_LOGGER .error ("Could not load attachments for {0}! (Exception: {1})" .format (source , e ))
245
247
246
- return result
248
+ return result , dependent_files
247
249
248
250
def compile_html (self , source , dest , is_two_file = False ):
249
251
makedirs (os .path .dirname (dest ))
@@ -254,9 +256,11 @@ def compile_html(self, source, dest, is_two_file=False):
254
256
if not is_two_file :
255
257
data = re .split ('(\n \n |\r \n \r \n )' , data , maxsplit = 1 )[- 1 ]
256
258
# Read additional data
257
- additional_data = self .load_additional_data (source )
259
+ additional_data , dependent_files = self .load_additional_data (source )
258
260
# Process post
259
261
context = Context (hash (data ), name = source , additional_data = additional_data )
262
+ for filename in dependent_files :
263
+ context .add_file_dependency (filename , 'fragment' )
260
264
output = self .__formatData (data , context )
261
265
# Write result
262
266
out_file .write (output )
0 commit comments