Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: getRemoteModuleList for incompatibility with runtime modules #927

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions apps/ll-cli/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void ensureDirectory(const std::filesystem::path &dir)
}

if (!std::filesystem::create_directory(dir, ec)) {
qCritical() << "failed to create directory:" << ec.message().c_str();
qCritical() << "failed to create directory :" << dir.c_str() << ec.message().c_str();
QCoreApplication::exit(ec.value());
std::abort();
}
Expand Down Expand Up @@ -307,10 +307,7 @@ ll-cli run org.deepin.demo -- bash -x /path/to/bash/script)"));
->group(CliAppManagingGroup)
->fallthrough();
cliKill->usage(_("Usage: ll-cli kill [OPTIONS] APP"));
cliKill
->add_option("APP",
options.appid,
_("Specify the running application"))
cliKill->add_option("APP", options.appid, _("Specify the running application"))
->required()
->check(validatorString);

Expand Down
31 changes: 27 additions & 4 deletions libs/linglong/src/linglong/repo/ostree_repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1892,14 +1892,37 @@ utils::error::Result<std::vector<std::string>> OSTreeRepo::getRemoteModuleList(
if (!list.has_value()) {
return LINGLONG_ERR("list remote reference", fuzzy);
}
if (list->size() == 0) {
return {};
}
auto include = [](const std::vector<std::string> &arr, const std::string &item) {
return std::find(arr.begin(), arr.end(), item) != arr.end();
};
std::vector<std::string> modules;
for (const auto &ref : *list) {
auto m = ref.packageInfoV2Module;
auto remoteModule = ref.packageInfoV2Module;
// 如果不筛选,返回所有module
if (!filter.has_value()) {
modules.push_back(m);
} else if (std::find(filter->begin(), filter->end(), m) != filter->end()) {
modules.push_back(m);
modules.push_back(remoteModule);
continue;
}
// 如果筛选,只返回指定的module
if (include(filter.value(), remoteModule)) {
modules.push_back(remoteModule);
continue;
}
// TODO 在未来删除对旧版本runtime module的兼容

// 如果过滤列表包含runtime,可以使用binary替换
// 这一般是在升级时,本地runtime模块升级到binary模块
if (remoteModule == "binary" && include(filter.value(), "runtime")) {
modules.push_back(remoteModule);
continue;
}
}
// 如果想安装binary模块,但远程没有binary模块,就安装runtime模块
if (include(filter.value(), "binary") && !include(modules, "binary")) {
modules.push_back("runtime");
}
std::sort(modules.begin(), modules.end());
auto it = std::unique(modules.begin(), modules.end());
Expand Down
2 changes: 1 addition & 1 deletion tools/test-linglong.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ ll-cli list | grep org.dde.calendar | grep -vq unuse
# 最新版本没有lang-ja模块,升级后删除lang-ja模块,保留其他模块
ll-cli upgrade org.dde.calendar
ll-cli list | grep org.dde.calendar | grep -q binary
ll-cli list | grep org.dde.calendar | grep -q develop
ll-cli list | grep org.dde.calendar | grep -vq lang-ja
ll-cli list | grep org.dde.calendar | grep -vq unuse
Loading