Don't include disabled apks in the index

This needs a rerun of `fdroid update --clean`.

In case a build is disabled delete_disabled_builds takes care of
deleting it from the repo. But this only works if the apk follows the
normal name pattern. Otherwise it will stay in the folder and be picked
up by process_apks and added to the index.

Closes: #1002
This commit is contained in:
Jochen Sprickerhof 2022-05-19 13:49:15 +02:00 committed by Hans-Christoph Steiner
parent 40f761c482
commit b07d23ff5c
2 changed files with 45 additions and 5 deletions

View file

@ -1716,6 +1716,38 @@ class UpdateTest(unittest.TestCase):
self.maxDiff = None
self.assertEqual(apkaapt, apkandroguard)
def test_exclude_disabled_apks(self):
testdir = tempfile.mkdtemp(
prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir
)
os.chdir(testdir)
os.mkdir('repo')
testapk = os.path.join('repo', 'com.politedroid_6.apk')
testapk_new = os.path.join('repo', 'Politedroid-1.5.apk')
shutil.copy(os.path.join(self.basedir, testapk), testapk_new)
config = dict()
fdroidserver.common.fill_config_defaults(config)
config['ndk_paths'] = dict()
fdroidserver.common.config = config
fdroidserver.update.config = config
fdroidserver.common.options = Options
fdroidserver.update.options = fdroidserver.common.options
fdroidserver.update.options.clean = True
app = fdroidserver.metadata.App()
app.id = 'com.politedroid'
apps = {app.id: app}
build = fdroidserver.metadata.Build()
build.versionCode = 6
build.disable = "disabled"
app['Builds'] = [build]
knownapks = fdroidserver.common.KnownApks()
apks, cachechanged = fdroidserver.update.process_apks({}, 'repo', knownapks, False, apps)
self.assertEqual([], apks)
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))