chiark / gitweb /
Fixes #8: if unknown APKs found, prompt to use -c or use --delete-unknown
authorHans-Christoph Steiner <hans@eds.org>
Thu, 29 May 2014 17:40:06 +0000 (13:40 -0400)
committerHans-Christoph Steiner <hans@eds.org>
Thu, 29 May 2014 17:40:06 +0000 (13:40 -0400)
This adds the option --delete-unknown for the current default behavior of
`fdroid update`: to delete any unknown APKs.  Instead, it just outputs a
warning about the unknown APKs and suggests -c for adding it.

Fixes #8 https://gitlab.com/fdroid/fdroidserver/issues/8

completion/bash-completion
fdroidserver/update.py

index 2b587ea735177b8233733e59b749e6894b4a69c1..ae47746e958e8939ca32764074e14181f0ba343b 100644 (file)
@@ -129,7 +129,7 @@ __complete_install() {
 __complete_update() {
        opts="-h -c -v -q -b -i -I -e -w"
        lopts="--help --createmeta --verbose --quiet --buildreport --interactive
- --icons --editor --wiki --pretty --clean"
+ --icons --editor --wiki --pretty --clean --delete-unknown"
        case "${prev}" in
                -e|--editor)
                        _filedir
index 8f18905283b3cb174b228d5b951c9e8280fbcf4a..f1506c814f8405554ca3e5d0f1e433fbc8b22ac8 100644 (file)
@@ -884,6 +884,8 @@ def main():
     parser = OptionParser()
     parser.add_option("-c", "--createmeta", action="store_true", default=False,
                       help="Create skeleton metadata files that are missing")
+    parser.add_option("--delete-unknown", action="store_true", default=False,
+                      help="Delete APKs without metadata from the repo")
     parser.add_option("-v", "--verbose", action="store_true", default=False,
                       help="Spew out even more information than normal")
     parser.add_option("-q", "--quiet", action="store_true", default=False,
@@ -1019,12 +1021,16 @@ def main():
                 f.close()
                 logging.info("Generated skeleton metadata for " + apk['id'])
             else:
-                logging.warn(apk['apkname'] + " (" + apk['id'] + ") has no metadata - removing")
-                rmf = os.path.join(repodirs[0], apk['apkname'])
-                if not os.path.exists(rmf):
-                    logging.error("Could not find {0} to remove it".format(rmf))
+                msg = apk['apkname'] + " (" + apk['id'] + ") has no metadata!"
+                if options.delete_unknown:
+                    logging.warn(msg + "\n\tdeleting: repo/" + apk['apkname'])
+                    rmf = os.path.join(repodirs[0], apk['apkname'])
+                    if not os.path.exists(rmf):
+                        logging.error("Could not find {0} to remove it".format(rmf))
+                    else:
+                        os.remove(rmf)
                 else:
-                    os.remove(rmf)
+                    logging.warn(msg + "\n\tUse `fdroid update -c` to create it.")
 
     if len(repodirs) > 1:
         archive_old_apks(apps, apks, archapks, repodirs[0], repodirs[1], config['archive_older'])