@@ -358,50 +358,6 @@ utils::error::Result<QString> commitDirToRepo(std::vector<GFile *> dirs,
358
358
return commit;
359
359
}
360
360
361
- utils::error::Result<void > initOstreeRepoConfig (
362
- OstreeRepo *repo, const linglong::api::types::v1::RepoConfigV2 &config) noexcept
363
- {
364
- LINGLONG_TRACE (" init ostree repo config" );
365
- g_autoptr (GError) gErr = nullptr ;
366
-
367
- const auto &defaultRepo = getDefaultRepo (config);
368
-
369
- g_auto (GStrv) remoteNames = ostree_repo_remote_list (repo, nullptr );
370
- if (remoteNames) {
371
- return LINGLONG_OK;
372
- }
373
- const std::string &remoteUrl = defaultRepo.url + " /repos/" + defaultRepo.name ;
374
- g_autoptr (GVariant) options = NULL ;
375
- GVariantBuilder builder;
376
- g_variant_builder_init (&builder, G_VARIANT_TYPE (" a{sv}" ));
377
- g_variant_builder_add (&builder, " {sv}" , " gpg-verify" , g_variant_new_boolean (FALSE ));
378
- g_variant_builder_add (&builder, " {sv}" , " http2" , g_variant_new_boolean (FALSE ));
379
- options = g_variant_ref_sink (g_variant_builder_end (&builder));
380
-
381
- if (ostree_repo_remote_change (repo,
382
- nullptr ,
383
- OSTREE_REPO_REMOTE_CHANGE_ADD,
384
- defaultRepo.alias .value_or (defaultRepo.name ).c_str (),
385
- remoteUrl.c_str (),
386
- options,
387
- nullptr ,
388
- &gErr )
389
- == FALSE ) {
390
- return LINGLONG_ERR (" ostree_repo_remote_change" , gErr );
391
- }
392
-
393
- GKeyFile *configKeyFile = ostree_repo_get_config (repo);
394
- Q_ASSERT (configKeyFile != nullptr );
395
-
396
- g_key_file_set_string (configKeyFile, " core" , " min-free-space-size" , " 600MB" );
397
-
398
- if (ostree_repo_write_config (repo, configKeyFile, &gErr ) == FALSE ) {
399
- return LINGLONG_ERR (" ostree_repo_write_config" , gErr );
400
- }
401
-
402
- return LINGLONG_OK;
403
- }
404
-
405
361
utils::error::Result<void >
406
362
updateOstreeRepoConfig (OstreeRepo *repo,
407
363
const linglong::api::types::v1::RepoConfigV2 &config,
@@ -412,20 +368,13 @@ updateOstreeRepoConfig(OstreeRepo *repo,
412
368
g_autoptr (GError) gErr = nullptr ;
413
369
414
370
g_auto (GStrv) remoteNames = ostree_repo_remote_list (repo, nullptr );
415
- if (!remoteNames) {
416
- return LINGLONG_ERR (" ostree_repo_remote_list Failed to get remote list" );
417
- }
418
-
419
- std::unordered_set<std::string> validRemotes;
420
- for (const auto &repoCfg : config.repos ) {
421
- validRemotes.insert (repoCfg.alias .value_or (repoCfg.name ));
422
- }
423
371
424
- for (auto remoteName = remoteNames; *remoteName != nullptr ; remoteName++) {
425
- if (validRemotes.find (*remoteName) == validRemotes.end ()) {
372
+ // 删除全部仓库
373
+ if (remoteNames != nullptr ) {
374
+ for (auto remoteName = remoteNames; *remoteName != nullptr ; remoteName++) {
426
375
if (ostree_repo_remote_change (repo,
427
376
nullptr ,
428
- OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS ,
377
+ OSTREE_REPO_REMOTE_CHANGE_DELETE ,
429
378
*remoteName,
430
379
nullptr ,
431
380
nullptr ,
@@ -449,18 +398,6 @@ updateOstreeRepoConfig(OstreeRepo *repo,
449
398
g_variant_builder_add (&builder, " {sv}" , " http2" , g_variant_new_boolean (FALSE ));
450
399
options = g_variant_ref_sink (g_variant_builder_end (&builder));
451
400
452
- if (ostree_repo_remote_change (repo,
453
- nullptr ,
454
- OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS,
455
- repoCfg.alias .value_or (repoCfg.name ).c_str (),
456
- nullptr ,
457
- nullptr ,
458
- nullptr ,
459
- &gErr )
460
- == FALSE ) {
461
- return LINGLONG_ERR (" ostree_repo_remote_change" , gErr );
462
- }
463
-
464
401
if (ostree_repo_remote_change (repo,
465
402
nullptr ,
466
403
OSTREE_REPO_REMOTE_CHANGE_ADD,
@@ -774,11 +711,6 @@ OSTreeRepo::OSTreeRepo(const QDir &path,
774
711
ostreeRepo = ostree_repo_new (repoPath);
775
712
Q_ASSERT (ostreeRepo != nullptr );
776
713
if (ostree_repo_open (ostreeRepo, nullptr , &gErr ) == TRUE ) {
777
- auto result = initOstreeRepoConfig (ostreeRepo, this ->cfg );
778
- if (!result) {
779
- qCritical () << LINGLONG_ERRV (result);
780
- qFatal (" abort" );
781
- }
782
714
783
715
this ->ostreeRepo .reset (static_cast <OstreeRepo *>(g_steal_pointer (&ostreeRepo)));
784
716
0 commit comments