delta: Do not create delta if all files are different
This commit is contained in:
@@ -21,6 +21,10 @@ import pisi.util as util
|
||||
import pisi.archive as archive
|
||||
|
||||
|
||||
class AllFilesChangedException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
# FIXME Reduce code duplication
|
||||
def create_delta_packages_from_obj(old_packages, new_package_obj, specdir):
|
||||
new_pkg_info = new_package_obj.metadata.package
|
||||
@@ -54,6 +58,14 @@ def create_delta_packages_from_obj(old_packages, new_package_obj, specdir):
|
||||
|
||||
old_pkg_files = old_pkg.get_files()
|
||||
|
||||
try:
|
||||
files_delta = find_delta(old_pkg_files, new_pkg_files)
|
||||
except AllFilesChangedException:
|
||||
ctx.ui.warning(_("All files in the package '%s' are different "
|
||||
"from the files in the new package. Skipping "
|
||||
"it...") % old_package)
|
||||
continue
|
||||
|
||||
delta_pkg = pisi.package.Package(delta_name, "w", format=target_format)
|
||||
|
||||
# add comar files to package
|
||||
@@ -68,8 +80,6 @@ def create_delta_packages_from_obj(old_packages, new_package_obj, specdir):
|
||||
delta_pkg.add_metadata_xml(ctx.const.metadata_xml)
|
||||
delta_pkg.add_files_xml(ctx.const.files_xml)
|
||||
|
||||
files_delta = find_delta(old_pkg_files, new_pkg_files)
|
||||
|
||||
# only metadata information may change in a package,
|
||||
# so no install archive added to delta package
|
||||
if files_delta:
|
||||
@@ -152,6 +162,14 @@ def create_delta_packages(old_packages, new_package):
|
||||
|
||||
old_pkg_files = old_pkg.get_files()
|
||||
|
||||
try:
|
||||
files_delta = find_delta(old_pkg_files, new_pkg_files)
|
||||
except AllFilesChangedException:
|
||||
ctx.ui.warning(_("All files in the package '%s' are different "
|
||||
"from the files in the new package. Skipping "
|
||||
"it...") % old_package)
|
||||
continue
|
||||
|
||||
delta_pkg = pisi.package.Package(delta_name, "w", format=target_format)
|
||||
|
||||
os.chdir(new_pkg_path)
|
||||
@@ -165,8 +183,6 @@ def create_delta_packages(old_packages, new_package):
|
||||
delta_pkg.add_metadata_xml(ctx.const.metadata_xml)
|
||||
delta_pkg.add_files_xml(ctx.const.files_xml)
|
||||
|
||||
files_delta = find_delta(old_pkg_files, new_pkg_files)
|
||||
|
||||
# only metadata information may change in a package,
|
||||
# so no install archive added to delta package
|
||||
if files_delta:
|
||||
@@ -210,6 +226,9 @@ def find_delta(old_files, new_files):
|
||||
old_hashes = set([f.hash for f in old_files.list])
|
||||
hashes_delta = new_hashes - old_hashes
|
||||
|
||||
if hashes_delta == new_hashes:
|
||||
raise AllFilesChangedException
|
||||
|
||||
deltas = []
|
||||
for h in hashes_delta:
|
||||
deltas.extend(hashto_files[h])
|
||||
|
||||
Reference in New Issue
Block a user