migliorie al check dell'hash
This commit is contained in:
@@ -11,6 +11,7 @@ import json
|
|||||||
import xbmc
|
import xbmc
|
||||||
import re
|
import re
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
|
from lib import githash
|
||||||
|
|
||||||
addon = xbmcaddon.Addon('plugin.video.kod')
|
addon = xbmcaddon.Addon('plugin.video.kod')
|
||||||
|
|
||||||
@@ -112,8 +113,7 @@ def check_addon_init():
|
|||||||
silent=True, continuar=True, resumir=False)
|
silent=True, continuar=True, resumir=False)
|
||||||
else: # è un file NON testuale, lo devo scaricare
|
else: # è un file NON testuale, lo devo scaricare
|
||||||
# se non è già applicato
|
# se non è già applicato
|
||||||
if not (filetools.isfile(addonDir + file['filename']) and getSha(
|
if not (filetools.isfile(addonDir + file['filename']) and getSha(addonDir + file['filename']) == file['sha']):
|
||||||
filetools.read(addonDir + file['filename']) == file['sha'])):
|
|
||||||
remove(addonDir + file["filename"])
|
remove(addonDir + file["filename"])
|
||||||
downloadtools.downloadfile(file['raw_url'], addonDir + file['filename'], silent=True,
|
downloadtools.downloadfile(file['raw_url'], addonDir + file['filename'], silent=True,
|
||||||
continuar=True, resumir=False)
|
continuar=True, resumir=False)
|
||||||
@@ -123,8 +123,7 @@ def check_addon_init():
|
|||||||
alreadyApplied = False
|
alreadyApplied = False
|
||||||
elif file['status'] == 'renamed':
|
elif file['status'] == 'renamed':
|
||||||
# se non è già applicato
|
# se non è già applicato
|
||||||
if not (filetools.isfile(addonDir + file['filename']) and getSha(
|
if not (filetools.isfile(addonDir + file['filename']) and getSha(addonDir + file['filename']) == file['sha']):
|
||||||
filetools.read(addonDir + file['filename']) == file['sha'])):
|
|
||||||
dirs = file['filename'].split('/')
|
dirs = file['filename'].split('/')
|
||||||
for d in dirs[:-1]:
|
for d in dirs[:-1]:
|
||||||
if not filetools.isdir(addonDir + d):
|
if not filetools.isdir(addonDir + d):
|
||||||
@@ -150,7 +149,6 @@ def check_addon_init():
|
|||||||
|
|
||||||
|
|
||||||
def calcCurrHash():
|
def calcCurrHash():
|
||||||
from lib import githash
|
|
||||||
treeHash = githash.tree_hash(addonDir).hexdigest()
|
treeHash = githash.tree_hash(addonDir).hexdigest()
|
||||||
logger.info('tree hash: ' + treeHash)
|
logger.info('tree hash: ' + treeHash)
|
||||||
commits = loadCommits()
|
commits = loadCommits()
|
||||||
@@ -210,8 +208,9 @@ def apply_patch(s,patch,revert=False):
|
|||||||
return t
|
return t
|
||||||
|
|
||||||
|
|
||||||
def getSha(fileText):
|
def getSha(path):
|
||||||
return hashlib.sha1("blob " + str(len(fileText)) + "\0" + fileText).hexdigest()
|
f = open(path).read()
|
||||||
|
return githash.generic_hash(path, '100644', len(f)).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
def updateFromZip():
|
def updateFromZip():
|
||||||
|
|||||||
Reference in New Issue
Block a user