If file could not be downloaded, raise an error about it. And if it is cached delete it before

starting a new operation. It is not deleted after download because it may be checked to see
what the problem is.

BUG:FIXED:4113
This commit is contained in:
Faik Uygur
2009-01-26 13:11:04 +00:00
parent 8c935c70cb
commit d64f21793c
2 changed files with 26 additions and 1 deletions
+16 -1
View File
@@ -27,6 +27,7 @@ import pisi.files
import pisi.uri
import pisi.ui
import pisi.version
import pisi.operations.helper
import pisi.operations.delta
import pisi.db
@@ -83,8 +84,10 @@ class Install(AtomicOperation):
# If delta exists than use the delta uri.
if delta:
pkg_uri = delta.packageURI
pkg_hash = delta.packageHash
else:
pkg_uri = pkg.packageURI
pkg_hash = pkg.packageHash
uri = pisi.uri.URI(pkg_uri)
if uri.is_absolute_path():
@@ -95,7 +98,19 @@ class Install(AtomicOperation):
ctx.ui.info(_("Package URI: %s") % pkg_path, verbose=True)
return Install(pkg_path, ignore_dep)
# Bug 4113
cached_file = pisi.package.Package.is_cached(pkg_path)
if cached_file and util.sha1_file(cached_file) != pkg_hash:
os.unlink(cached_file)
install_op = Install(pkg_path, ignore_dep)
# Bug 4113
downloaded_file = install_op.package.filepath
if pisi.util.sha1_file(downloaded_file) != pkg_hash:
raise pisi.Error(_("Download Error: Package does not match the repository package."))
return install_op
else:
raise Error(_("Package %s not found in any active repository.") % name)
+10
View File
@@ -142,3 +142,13 @@ class Package:
def comar_dir(self):
return os.path.join(self.pkg_dir(), ctx.const.comar_dir)
@staticmethod
def is_cached(packagefn):
url = pisi.uri.URI(packagefn)
filepath = packagefn
if url.is_remote_file():
filepath = os.path.join(ctx.config.cached_packages_dir(), url.filename())
return os.path.exists(filepath) and filepath
else:
return filepath