Added abbility to upload custom rpm to the projects repo

This commit is contained in:
Alexey Berezhok
2026-04-17 18:03:36 +03:00
parent cbe4505d1e
commit 6139670677
4 changed files with 119 additions and 1 deletions

View File

@@ -538,4 +538,40 @@ class ProjectsActions
FileUtils.cp_r(Dir.glob(File.join(snap_path, '*')), repo_path)
end
end
def get_repo_dirs_list(id)
repo_path = get_project_repo(id)
dir_list = []
if Dir.exist?(repo_path)
dir_list = Dir.entries(repo_path).reject { |entry| entry == '.' || entry == '..' || entry == 'repodata' }
end
dir_list
end
def add_rpm(id, directory, rpm_file)
repo_path = get_project_repo(id)
if !Dir.exist?(repo_path)
return "Репозиторий отсутствует"
end
target_dir = File.join(repo_path, directory)
unless Dir.exist?(target_dir)
Dir.mkdir(target_dir)
end
target_file = File.join(target_dir, File.basename(rpm_file[:filename]))
if File.exist?(target_file)
return "Файл #{File.basename(rpm_file[:filename])} уже существует"
end
begin
File.open(target_file, "wb") do |file|
file.write(rpm_file[:tempfile].read)
end
rescue => e
return "Ошибка при создании файла: #{e.message}"
end
nil
end
end