ContentManager: split verifyFile() into 2 functions and always log the verify error at INFO level
This commit is contained in:
parent
7354d712e0
commit
5d5b3684cc
1 changed files with 98 additions and 93 deletions
|
@ -925,12 +925,9 @@ class ContentManager(object):
|
||||||
|
|
||||||
return True # All good
|
return True # All good
|
||||||
|
|
||||||
# Verify file validity
|
def verifyContentJson(self, inner_path, file, ignore_same=True):
|
||||||
# Return: None = Same as before, False = Invalid, True = Valid
|
|
||||||
def verifyFile(self, inner_path, file, ignore_same=True):
|
|
||||||
if inner_path.endswith("content.json"): # content.json: Check using sign
|
|
||||||
from Crypt import CryptBitcoin
|
from Crypt import CryptBitcoin
|
||||||
try:
|
|
||||||
if type(file) is dict:
|
if type(file) is dict:
|
||||||
new_content = file
|
new_content = file
|
||||||
else:
|
else:
|
||||||
|
@ -1001,11 +998,7 @@ class ContentManager(object):
|
||||||
else: # Old style signing
|
else: # Old style signing
|
||||||
raise VerifyError("Invalid old-style sign")
|
raise VerifyError("Invalid old-style sign")
|
||||||
|
|
||||||
except Exception as err:
|
def verifyOrdinaryFile(self, inner_path, file, ignore_same=True):
|
||||||
self.log.warning("%s: verify sign error: %s" % (inner_path, Debug.formatException(err)))
|
|
||||||
raise err
|
|
||||||
|
|
||||||
else: # Check using sha512 hash
|
|
||||||
file_info = self.getFileInfo(inner_path)
|
file_info = self.getFileInfo(inner_path)
|
||||||
if file_info:
|
if file_info:
|
||||||
if CryptHash.sha512sum(file) != file_info.get("sha512", ""):
|
if CryptHash.sha512sum(file) != file_info.get("sha512", ""):
|
||||||
|
@ -1022,6 +1015,18 @@ class ContentManager(object):
|
||||||
else: # File not in content.json
|
else: # File not in content.json
|
||||||
raise VerifyError("File not in content.json")
|
raise VerifyError("File not in content.json")
|
||||||
|
|
||||||
|
# Verify file validity
|
||||||
|
# Return: None = Same as before, False = Invalid, True = Valid
|
||||||
|
def verifyFile(self, inner_path, file, ignore_same=True):
|
||||||
|
try:
|
||||||
|
if inner_path.endswith("content.json"):
|
||||||
|
return self.verifyContentJson(inner_path, file, ignore_same)
|
||||||
|
else:
|
||||||
|
return self.verifyOrdinaryFile(inner_path, file, ignore_same)
|
||||||
|
except Exception as err:
|
||||||
|
self.log.info("%s: verify error: %s" % (inner_path, Debug.formatException(err)))
|
||||||
|
raise err
|
||||||
|
|
||||||
def optionalDelete(self, inner_path):
|
def optionalDelete(self, inner_path):
|
||||||
self.site.storage.delete(inner_path)
|
self.site.storage.delete(inner_path)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue