forked from github.com/pypiserver
Refuse to re upload existing file
This commit is contained in:
parent
5cb109515c
commit
b8c775c4d7
@ -110,7 +110,9 @@ def update():
|
|||||||
if "/" in content.filename:
|
if "/" in content.filename:
|
||||||
raise HTTPError(400, output="bad filename")
|
raise HTTPError(400, output="bad filename")
|
||||||
|
|
||||||
packages.store(content.filename, content.value)
|
if not packages.store(content.filename, content.value):
|
||||||
|
raise HTTPError(409, output="file already exists")
|
||||||
|
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@ -68,10 +68,14 @@ class pkgset(object):
|
|||||||
def store(self, filename, data):
|
def store(self, filename, data):
|
||||||
assert "/" not in filename
|
assert "/" not in filename
|
||||||
dest_fn = os.path.join(self.root, filename)
|
dest_fn = os.path.join(self.root, filename)
|
||||||
dest_fh = open(dest_fn, "wb")
|
if not os.path.exists(dest_fn):
|
||||||
|
dest_fh = open(dest_fn, "wb")
|
||||||
|
|
||||||
dest_fh.write(data)
|
dest_fh.write(data)
|
||||||
dest_fh.close()
|
dest_fh.close()
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
|
Loading…
Reference in New Issue
Block a user