aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2015-01-28 13:18:55 -0600
committerAndy Doan <andy.doan@linaro.org>2015-01-28 13:18:55 -0600
commitb4e9be816dfc2aed6cbdc1680da89d7d72afc4ef (patch)
treeb61e5d43bbd2115c079c28267d915113ac74984b
parent9acb2f4a943890146529ee8d88214ec3d8d306d4 (diff)
downloadlinaro-license-protection-b4e9be816dfc2aed6cbdc1680da89d7d72afc4ef.tar.gz
fix link-latest issue2015.01
The logic was broken for a dangling symlink. Change-Id: I0f27f12a34e9525cd48f0e2d2be6b0697842ffce
-rw-r--r--license_protected_downloads/api/v2.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/license_protected_downloads/api/v2.py b/license_protected_downloads/api/v2.py
index ecd2c32..f58468c 100644
--- a/license_protected_downloads/api/v2.py
+++ b/license_protected_downloads/api/v2.py
@@ -166,12 +166,11 @@ class LatestLinkResource(PublishResource):
raise HttpResponseError('Invalid link name', 401)
dst = os.path.join(os.path.dirname(src), link_name)
+ if os.path.islink(dst):
+ os.unlink(dst)
if os.path.exists(dst):
- if os.path.islink(dst):
- os.unlink(dst)
- else:
- APILog.mark(self.request, 'INVALID_ARGUMENTS', self.api_key)
- raise HttpResponseError('Invalid destination', 404)
+ APILog.mark(self.request, 'INVALID_ARGUMENTS', self.api_key)
+ raise HttpResponseError('Invalid destination', 404)
os.symlink(src, dst)
APILog.mark(self.request, 'LINK_LATEST', self.api_key)