strip file extension from generated name for non-APKs

With a generic file, the file name is the only guaranteed name metadata
field.  So if the name is not specified in the metadata, then the name
is set to the filename.  This changes that so that the file extension is
stripped from that generated name.
This commit is contained in:
Hans-Christoph Steiner 2017-06-01 10:29:30 +02:00
parent 6105f8a184
commit 372c8b418d
3 changed files with 3 additions and 3 deletions

View File

@ -448,7 +448,7 @@ def make_v0(apps, apks, repodir, repodict, requestsdict):
and repodir == 'repo': # only create these
namefield = common.config['current_version_name_source']
sanitized_name = re.sub(b'''[ '"&%?+=/]''', b'', app.get(namefield).encode('utf-8'))
apklinkname = sanitized_name + b'.apk'
apklinkname = sanitized_name + os.path.splitext(current_version_file)[1].encode('utf-8')
current_version_path = os.path.join(repodir, current_version_file).encode('utf-8', 'surrogateescape')
if os.path.islink(apklinkname):
os.remove(apklinkname)

View File

@ -843,8 +843,8 @@ def scan_repo_files(apkcache, repodir, knownapks, use_date_from_file=False):
if not usecache:
logging.debug("Processing " + name_utf8)
repo_file = collections.OrderedDict()
repo_file['name'] = os.path.splitext(name_utf8)[0]
# TODO rename apkname globally to something more generic
repo_file['name'] = name_utf8
repo_file['apkName'] = name_utf8
repo_file['hash'] = shasum
repo_file['hashType'] = 'sha256'

View File

@ -12,7 +12,7 @@
<id>fake.ota.update</id>
<added>2016-03-10</added>
<lastupdated>2016-03-10</lastupdated>
<name>fake.ota.update_1234.zip</name>
<name>fake.ota.update_1234</name>
<summary>Tests whether OTA ZIP files are being include</summary>
<desc>&lt;p&gt;F-Droid can make use of system privileges or permissions to install, update and remove applications on its own. The only way to obtain those privileges is to become a system app.&lt;/p&gt;&lt;p&gt;This is where the Privileged Extension comes in - being a separate app and much smaller, it can be installed as a system app and communicate with the main app via AIDL IPC.&lt;/p&gt;&lt;p&gt;This has several advantages:&lt;/p&gt;&lt;ul&gt;&lt;li&gt; Reduced disk usage in the system partition&lt;/li&gt;&lt;li&gt; System updates don't remove F-Droid&lt;/li&gt;&lt;li&gt; The process of installing into system via root is safer&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This is packaged as an OTA (Over-The-Air) update ZIP file. It must be installed using TWRP or other Android recovery that can flash updates to the system from the /data/data/org.fdroid.fdroid folder on the /data partition. The standalone APK is called F-Droid Privileged Extension.&lt;/p&gt;</desc>
<license>Apache-2.0</license>