def check_for_collisions(parts): """Raises a SnapcraftPartConflictError if conflicts are found.""" parts_files = {} for part in parts: # Gather our own files up part_files, _ = part.migratable_fileset_for('stage') # Scan previous parts for collisions for other_part_name in parts_files: common = part_files & parts_files[other_part_name]['files'] conflict_files = [] for f in common: this = os.path.join(part.installdir, f) other = os.path.join( parts_files[other_part_name]['installdir'], f) if os.path.exists(this) and os.path.exists(other): if os.path.islink(this) and os.path.islink(other): continue if _file_collides(this, other): conflict_files.append(f) if conflict_files: raise errors.SnapcraftPartConflictError( other_part_name=other_part_name, part_name=part.name, conflict_files=conflict_files) # And add our files to the list parts_files[part.name] = { 'files': part_files, 'installdir': part.installdir }
def check_for_collisions(parts): """Raises a SnapcraftPartConflictError if conflicts are found.""" parts_files = {} for part in parts: # Gather our own files up part_files, part_directories = part.migratable_fileset_for(steps.STAGE) part_contents = part_files | part_directories # Scan previous parts for collisions for other_part_name in parts_files: common = part_contents & parts_files[other_part_name]["files"] conflict_files = [] for f in common: this = os.path.join(part.plugin.installdir, f) other = os.path.join(parts_files[other_part_name]["installdir"], f) if _paths_collide(this, other): conflict_files.append(f) if conflict_files: raise errors.SnapcraftPartConflictError( other_part_name=other_part_name, part_name=part.name, conflict_files=conflict_files, ) # And add our files to the list parts_files[part.name] = { "files": part_contents, "installdir": part.plugin.installdir, }