Skip to content

Commit 00aba5c

Browse files
committed
move safe_write to after parse
1 parent 589d466 commit 00aba5c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/pyff/resource.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ def load_backup(self, r):
308308
return None
309309

310310
def load_resource(self, getter):
311-
info = self.add_info()
312311
data: Optional[str] = None
313312
status: Optional[int] = None
313+
info = self.add_info()
314314

315315
log.debug("Loading resource {}".format(self.url))
316316

@@ -348,21 +348,21 @@ def load_resource(self, getter):
348348
if data is None or not len(data) > 0:
349349
raise ResourceException("Got status={:d} while getting {}".format(r.status_code, self.url))
350350

351-
if status == 200:
352-
self.last_seen = utc_now().replace(microsecond=0)
353-
safe_write(self.local_copy_fn, data, True)
354-
355351
info['State'] = 'Fetched'
356352

357-
return data, info
353+
return data, status, info
358354

359355
def parse(self, getter):
360-
data, info = self.load_resource(getter)
356+
data, status, info = self.load_resource(getter)
361357
info['State'] = 'Parsing'
362358
parse_info = parse_resource(self, data)
363359
if parse_info is not None and isinstance(parse_info, dict):
364360
info.update(parse_info)
365361

362+
if status == 200:
363+
self.last_seen = utc_now().replace(microsecond=0)
364+
safe_write(self.local_copy_fn, data, True)
365+
366366
info['State'] = 'Parsed'
367367
if self.t is not None:
368368
if self.post and isinstance(self.post, list):

0 commit comments

Comments
 (0)