Skip to content

Commit

Permalink
WIP: Refactor package.rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas authored and Dany Marcoux committed Apr 26, 2021
1 parent 249fdb6 commit fb01143
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/api/app/models/token/rebuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,29 @@ def self.token_name
'rebuild'
end

def call(pkg)
rebuild(pkg)
end
def call(params)
package_name = package&.name || params[:package]
project_name = package&.project.name || params[:project]

def rebuild(pkg)
pkg.rebuild({ project: pkg.project, package: pkg })
Backend::Api::Sources::Package.rebuild(project_name, package_name, params)
end

def package_find_options
# authorization needs to check:
# sourceaccess => package.check_source_access?
# follow_multibuild => already handled by backend (packages names with '*:' in the name)

opts = if @token.instance_of?(Token::Rebuild)
{ use_source: false,
follow_project_links: true,
follow_multibuild: true }
else
{ use_source: true,
follow_project_links: false,
follow_multibuild: false }
end

@pkg = Package.get_by_project_and_name(params[:project].to_s, params[:package].to_s, opts)

end

####
Expand Down

0 comments on commit fb01143

Please sign in to comment.