chiark / gitweb /
Don't use exists() on symlinks
authorDaniel Martí <mvdan@mvdan.cc>
Thu, 1 Oct 2015 00:04:00 +0000 (17:04 -0700)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 1 Oct 2015 00:05:44 +0000 (17:05 -0700)
If they are broken, exists() will return false. islink() will return true in
both cases.

fdroidserver/update.py

index 29dbad8d53cf99fb68b98d62dfaf9d80ecd2a960..af5340c83dbc3538f4d6fd883842cbcf03857625 100644 (file)
@@ -911,7 +911,7 @@ def make_index(apps, sortedids, apks, repodir, archive, categories):
                                     app[config['current_version_name_source']])
             apklinkname = sanitized_name + '.apk'
             current_version_path = os.path.join(repodir, current_version_file)
-            if os.path.exists(apklinkname):
+            if os.path.islink(apklinkname):
                 os.remove(apklinkname)
             os.symlink(current_version_path, apklinkname)
             # also symlink gpg signature, if it exists
@@ -919,7 +919,7 @@ def make_index(apps, sortedids, apks, repodir, archive, categories):
                 sigfile_path = current_version_path + extension
                 if os.path.exists(sigfile_path):
                     siglinkname = apklinkname + extension
-                    if os.path.exists(siglinkname):
+                    if os.path.islink(siglinkname):
                         os.remove(siglinkname)
                     os.symlink(sigfile_path, siglinkname)