Added list of uploaded rpm

This commit is contained in:
Alexey Berezhok
2026-04-18 00:11:36 +03:00
parent 6139670677
commit 0828293f36
9 changed files with 171 additions and 2 deletions

85
app.rb
View File

@@ -1831,6 +1831,91 @@ post "/prjsnap_restore/:id" do
end
end
get "/prjuplrpm/:id" do
@raw = nil
prj = ProjectsActions.new(cfg.get_projects_path, db)
if prj.path.nil?
print_error_page(503, "Путь к проектам не существует")
else
prj_info = prj.get_project(params["id"])
if params["p"].nil?
filepath = ""
else
filepath = params["p"]
end
proj_path = prj.get_project_repo(params["id"])
f_path = File.join(proj_path, filepath)
if File.exist?(f_path)
if File.directory?(f_path)
@file_content = []
else
if File.binary?(f_path)
if f_path =~ /\.rpm$/
rpm_rd = RPMReader.new
rpm_info = rpm_rd.get_rpm_info(f_path)
if rpm_info[:error].nil?
@raw = f_path
rpm_info = rpm_info[:pkginfo]
@file_content = []
@file_content << "Имя пакета: #{rpm_info.name}"
@file_content << "Версия пакета: #{rpm_info.version}"
@file_content << ""
@file_content << "Changelog:"
begin
rpm_info.changelog.first(10).each do |entry|
@file_content << "#{entry.time} #{entry.name}"
@file_content << "#{entry.text}"
@file_content << "---------------"
end
rescue
# Если есть ошибка с undefined local variable or method, пропускаем changelog
@file_content << "Changelog недоступен"
end
@file_content << "---------------"
@file_content << "Файлы:"
rpm_info.files.each do |file|
@file_content << "#{file.path} (#{file.size})"
end
@file_content << "---------------"
@file_content << "Зависимости:"
rpm_info.provides.each do |item|
@file_content << "Provides: #{item.name}"
end
rpm_info.requires.each do |item|
@file_content << "Requires: #{item.name}"
end
rpm_info.obsoletes.each do |item|
@file_content << "Obsoletes: #{item.name}"
end
rpm_info.conflicts.each do |item|
@file_content << "Conflicts: #{item.name}"
end
else
@file_content = ["Двоичный файл"]
end
else
@file_content = ["Двоичный файл"]
end
else
@file_content = File.readlines(f_path)
end
end
@files_list = prj.get_project_uploaded_rpms(params["id"]).map do |item|
{ :file => item[:rpm_path].delete_prefix(proj_path + "/"), :isdir => false, :create_time => item[:create_at] }
end
@page_name = "Список загруженных rpm пакетов для проекта #{prj_info[:projname]}"
@proj_info = prj_info
@file_name = filepath
erb :rpmuploadinfo
else
print_error_page(503, "Файл не существует")
end
end
end
get "/sanitize" do
#Подчистим гит проекты, которые есть в базе, но нет в файловой системе