From: Hans-Christoph Steiner Date: Tue, 19 Sep 2017 08:57:29 +0000 (+0200) Subject: allow spaces in filenames X-Git-Tag: 0.9~74^2~9 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=176f539647a6c343ebc41284d0a9608a012f85eb;p=fdroidserver.git 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 --- diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 807974d6..c8442d5e 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1599,6 +1599,13 @@ class KnownApks: """ 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.apks = {} if os.path.isfile(self.path): @@ -1608,7 +1615,10 @@ class KnownApks: if len(t) == 2: self.apks[t[0]] = (t[1], None) 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 def writeifchanged(self): diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 65379276..99fb80e5 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -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. """ - 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 = {} apkfile = os.path.join(repodir, apkfilename) diff --git a/tests/run-tests b/tests/run-tests index 8558794e..e0986b97 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -8,14 +8,14 @@ echo_header() { copy_apks_into_repo() { set +x - for f in `find $APKDIR -name '*.apk' | grep -F -v -e unaligned -e unsigned -e badsig -e badcert -e bad-unicode`; do - name=$(basename $(dirname `dirname $f`)) + find $APKDIR -type f -name '*.apk' -print0 | while IFS= read -r -d '' f; do + 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"` - 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 echo "$f --> repo/$apk" - ln $f $1/repo/$apk || \ - rsync -axv $f $1/repo/$apk # rsync if hard link is not possible + ln "$f" $1/repo/$apk || \ + rsync -axv "$f" $1/repo/$apk # rsync if hard link is not possible fi done set -x