mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-09 15:37:56 -05:00
crew: Rubyize file conflict algorithm (#11734)
* crew: Rubyize conflict algorithm Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Update code comments Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * const: Bump version Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Also check for essential files on removal Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Fix syntax Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Fix unit test Signed-off-by: SupeChicken666 <supechicken666@gmail.com> --------- Signed-off-by: SupeChicken666 <supechicken666@gmail.com>
This commit is contained in:
@@ -7,6 +7,26 @@ require_relative 'crewlog'
|
||||
require_relative 'downloader'
|
||||
|
||||
class ConvenienceFunctions
|
||||
def self.determine_conflicts(pkgName, filelist = File.join(CREW_META_PATH, "#{pkgName}.filelist"), excludeSuffix = nil, verbose: false)
|
||||
conflicts = {}
|
||||
target_filelist = File.readlines(filelist, chomp: true)
|
||||
|
||||
puts 'Checking for conflicts with files from installed packages...'.orange if verbose
|
||||
|
||||
Dir[File.join(CREW_META_PATH, "*.filelist")].each do |filelist|
|
||||
filelist_name = File.basename(filelist, ".filelist")
|
||||
|
||||
# skip filelist belongs to the same package/explicitly excluded
|
||||
next if pkgName == filelist_name || (excludeSuffix && filelist_name.end_with?(excludeSuffix))
|
||||
|
||||
# find out identical file paths with intersection
|
||||
conflict = (target_filelist & File.readlines(filelist, chomp: true)).reject(&:empty?)
|
||||
conflicts[filelist_name] = conflict if conflict.any?
|
||||
end
|
||||
|
||||
return conflicts
|
||||
end
|
||||
|
||||
def self.load_symbolized_json
|
||||
return JSON.load_file(File.join(CREW_CONFIG_PATH, 'device.json'), symbolize_names: true).transform_values! { |val| val.is_a?(String) ? val.to_sym : val }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user