Merge pull request #118 from zeronet-conservancy/fix_modified_parsing
Fix `modified` parsing
This commit is contained in:
commit
53ba8d2bb9
1 changed files with 10 additions and 10 deletions
|
@ -78,19 +78,19 @@ class ContentManager(object):
|
||||||
|
|
||||||
if os.path.isfile(content_path):
|
if os.path.isfile(content_path):
|
||||||
try:
|
try:
|
||||||
|
new_content = self.site.storage.loadJson(content_inner_path)
|
||||||
# Check if file is newer than what we have
|
# Check if file is newer than what we have
|
||||||
if not force and old_content and not self.site.settings.get("own"):
|
if not force and old_content and not self.site.settings.get("own"):
|
||||||
for line in open(content_path):
|
new_ts = int(float(new_content.get('modified', 0)))
|
||||||
if '"modified"' not in line:
|
old_ts = int(float(old_content.get('modified', 0)))
|
||||||
continue
|
if new_ts < old_ts:
|
||||||
match = re.search(r"([0-9\.]+),$", line.strip(" \r\n"))
|
self.log.debug('got older version of {content_inner_path} ({new_ts} < {old_ts}), ignoring')
|
||||||
if match and float(match.group(1)) <= old_content.get("modified", 0):
|
return [], []
|
||||||
self.log.debug("%s loadContent same json file, skipping" % content_inner_path)
|
elif new_ts == old_ts:
|
||||||
return [], []
|
self.log.debug('got same timestamp version of {content_inner_path} ({new_ts}), ignoring')
|
||||||
|
return [], []
|
||||||
new_content = self.site.storage.loadJson(content_inner_path)
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.log.warning("%s load error: %s" % (content_path, Debug.formatException(err)))
|
self.log.warning(f'{content_path} load error: {Debug.formatException(err)}')
|
||||||
return [], []
|
return [], []
|
||||||
else:
|
else:
|
||||||
self.log.debug("Content.json not exist: %s" % content_path)
|
self.log.debug("Content.json not exist: %s" % content_path)
|
||||||
|
|
Loading…
Reference in a new issue