Skip to content

Commit

Permalink
added Patch.read_license method
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladislav Slezak committed Jan 2, 2013
1 parent 2e526c5 commit aea1e50
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plugins/software/app/models/patch.rb
Expand Up @@ -60,6 +60,11 @@ def self.install_patches(patches)
end
end

# read the license file, returns [package_id, patch_id, license_text]
def self.read_license file
File.read(file).split("\n", 3)
end

public

def self.accept_license name
Expand Down Expand Up @@ -348,7 +353,7 @@ def self.license
Dir.glob(File.join(LICENSES_DIR,"*")).reduce([]) do |res,f|
if File.file? f
# there is package_id on the first line
package_id, patch_id, text = File.read(f).split("\n", 3)
package_id, patch_id, text = read_license f
res << ({
:name => File.basename(f),
:text => text,
Expand Down Expand Up @@ -468,7 +473,7 @@ def self.remove_eulas(pk_id)
dir.each do |filename|
unless File.directory? filename
license_file = File.join(ACCEPTED_LICENSES_DIR, filename)
package_id, patch_id, text = File.read(license_file).split("\n", 3)
package_id, patch_id, text = read_license license_file
Rails.logger.debug "File: #{filename}, license for: #{package_id} - #{patch_id}"

if patch_id == pk_id
Expand Down

0 comments on commit aea1e50

Please sign in to comment.