1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-04 02:00:11 +02:00

allow spaces in filenames

This fixes all the bugs I could find that prevented fdroid from
handling files with spaces in them.  This is more important now that
fdroid supports random media files, and Repomaker
This commit is contained in:
Hans-Christoph Steiner 2017-09-19 10:57:29 +02:00
parent 6adf309bef
commit 176f539647
3 changed files with 16 additions and 16 deletions

View File

@ -1599,6 +1599,13 @@ class KnownApks:
""" """
def __init__(self): def __init__(self):
'''Load filename/date info about previously seen APKs
Since the appid and date strings both will never have spaces,
this is parsed as a list from the end to allow the filename to
have any combo of spaces.
'''
self.path = os.path.join('stats', 'known_apks.txt') self.path = os.path.join('stats', 'known_apks.txt')
self.apks = {} self.apks = {}
if os.path.isfile(self.path): if os.path.isfile(self.path):
@ -1608,7 +1615,10 @@ class KnownApks:
if len(t) == 2: if len(t) == 2:
self.apks[t[0]] = (t[1], None) self.apks[t[0]] = (t[1], None)
else: else:
self.apks[t[0]] = (t[1], datetime.strptime(t[2], '%Y-%m-%d')) appid = t[-2]
date = datetime.strptime(t[-1], '%Y-%m-%d')
filename = line[0:line.rfind(appid) - 1]
self.apks[filename] = (appid, date)
self.changed = False self.changed = False
def writeifchanged(self): def writeifchanged(self):

View File

@ -1197,16 +1197,6 @@ def process_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk=Fal
apk is the scanned apk information, and cachechanged is True if the apkcache got changed. apk is the scanned apk information, and cachechanged is True if the apkcache got changed.
""" """
if ' ' in apkfilename:
if options.rename_apks:
newfilename = apkfilename.replace(' ', '_')
os.rename(os.path.join(repodir, apkfilename),
os.path.join(repodir, newfilename))
apkfilename = newfilename
else:
logging.critical("Spaces in filenames are not allowed.")
return True, None, False
apk = {} apk = {}
apkfile = os.path.join(repodir, apkfilename) apkfile = os.path.join(repodir, apkfilename)

View File

@ -8,14 +8,14 @@ echo_header() {
copy_apks_into_repo() { copy_apks_into_repo() {
set +x set +x
for f in `find $APKDIR -name '*.apk' | grep -F -v -e unaligned -e unsigned -e badsig -e badcert -e bad-unicode`; do find $APKDIR -type f -name '*.apk' -print0 | while IFS= read -r -d '' f; do
name=$(basename $(dirname `dirname $f`)) echo $f | grep -F -v -e unaligned -e unsigned -e badsig -e badcert -e bad-unicode || continue
apk=`$aapt dump badging "$f" | sed -n "s,^package: name='\(.*\)' versionCode='\([0-9][0-9]*\)' .*,\1_\2.apk,p"` apk=`$aapt dump badging "$f" | sed -n "s,^package: name='\(.*\)' versionCode='\([0-9][0-9]*\)' .*,\1_\2.apk,p"`
test $f -nt repo/$apk && rm -f repo/$apk # delete existing if $f is newer test "$f" -nt repo/$apk && rm -f repo/$apk # delete existing if $f is newer
if [ ! -e repo/$apk ] && [ ! -e archive/$apk ]; then if [ ! -e repo/$apk ] && [ ! -e archive/$apk ]; then
echo "$f --> repo/$apk" echo "$f --> repo/$apk"
ln $f $1/repo/$apk || \ ln "$f" $1/repo/$apk || \
rsync -axv $f $1/repo/$apk # rsync if hard link is not possible rsync -axv "$f" $1/repo/$apk # rsync if hard link is not possible
fi fi
done done
set -x set -x