Commit 3b0abff6 authored by Seblu's avatar Seblu

Handle overwrite of local files in Url class

parent df88fb24
......@@ -102,8 +102,10 @@ class Url(object):
raise Error(f"Failed to get headers at {self}: {exp}")
return getattr(self, "_headers")
def download(self, destination):
def download(self, destination, overwrite=True):
"""Download URL to destination"""
if not overwrite and exists(destination):
raise Error(f"Local file {destination} already exists")
debug(f"Downloading from : {self.url}")
debug(f" to : {destination}")
try:
......@@ -154,14 +156,9 @@ class Package(Url):
def get(self, sign=True, force=False):
"""Download the package locally"""
if not force:
if exists(self.filename):
raise Error(f"Local file {self.filename} already exists")
if sign and exists(self.sigfilename):
raise Error(f"Local file {self.sigfilename} already exists")
self.url.download(self.filename)
self.url.download(self.filename, force)
if sign and self.sigurl.exists:
self.sigurl.download(self.sigfilename)
self.sigurl.download(self.sigfilename, force)
class Archive(object):
"""Abstract access to the package Archive"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment