mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 15:00:30 +03:00
Detect apk cache changes to avoid having to blow the whole thing
This commit is contained in:
parent
75aa384e80
commit
b5ed40684f
1 changed files with 20 additions and 14 deletions
|
|
@ -421,14 +421,30 @@ def scan_apks(apps, apkcache, repodir, knownapks):
|
||||||
logging.critical("Spaces in filenames are not allowed.")
|
logging.critical("Spaces in filenames are not allowed.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if apkfilename in apkcache:
|
# Calculate the sha256...
|
||||||
logging.debug("Reading " + apkfilename + " from cache")
|
sha = hashlib.sha256()
|
||||||
thisinfo = apkcache[apkfilename]
|
with open(apkfile, 'rb') as f:
|
||||||
|
while True:
|
||||||
|
t = f.read(16384)
|
||||||
|
if len(t) == 0:
|
||||||
|
break
|
||||||
|
sha.update(t)
|
||||||
|
shasum = sha.hexdigest()
|
||||||
|
|
||||||
else:
|
usecache = False
|
||||||
|
if apkfilename in apkcache:
|
||||||
|
thisinfo = apkcache[apkfilename]
|
||||||
|
if thisinfo['sha256'] == shasum:
|
||||||
|
logging.debug("Reading " + apkfilename + " from cache")
|
||||||
|
usecache = True
|
||||||
|
else:
|
||||||
|
logging.debug("Ignoring stale cache data for " + apkfilename)
|
||||||
|
|
||||||
|
if not usecache:
|
||||||
logging.debug("Processing " + apkfilename)
|
logging.debug("Processing " + apkfilename)
|
||||||
thisinfo = {}
|
thisinfo = {}
|
||||||
thisinfo['apkname'] = apkfilename
|
thisinfo['apkname'] = apkfilename
|
||||||
|
thisinfo['sha256'] = shasum
|
||||||
srcfilename = apkfilename[:-4] + "_src.tar.gz"
|
srcfilename = apkfilename[:-4] + "_src.tar.gz"
|
||||||
if os.path.exists(os.path.join(repodir, srcfilename)):
|
if os.path.exists(os.path.join(repodir, srcfilename)):
|
||||||
thisinfo['srcname'] = srcfilename
|
thisinfo['srcname'] = srcfilename
|
||||||
|
|
@ -514,16 +530,6 @@ def scan_apks(apps, apkcache, repodir, knownapks):
|
||||||
if common.isApkDebuggable(apkfile, config):
|
if common.isApkDebuggable(apkfile, config):
|
||||||
logging.warn('{0} is set to android:debuggable="true"'.format(apkfile))
|
logging.warn('{0} is set to android:debuggable="true"'.format(apkfile))
|
||||||
|
|
||||||
# Calculate the sha256...
|
|
||||||
sha = hashlib.sha256()
|
|
||||||
with open(apkfile, 'rb') as f:
|
|
||||||
while True:
|
|
||||||
t = f.read(1024)
|
|
||||||
if len(t) == 0:
|
|
||||||
break
|
|
||||||
sha.update(t)
|
|
||||||
thisinfo['sha256'] = sha.hexdigest()
|
|
||||||
|
|
||||||
# Get the signature (or md5 of, to be precise)...
|
# Get the signature (or md5 of, to be precise)...
|
||||||
thisinfo['sig'] = getsig(os.path.join(os.getcwd(), apkfile))
|
thisinfo['sig'] = getsig(os.path.join(os.getcwd(), apkfile))
|
||||||
if not thisinfo['sig']:
|
if not thisinfo['sig']:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue