From a2bcf35e0dbf96f7bbc73b878f5151d9d74f1288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Mon, 11 Apr 2022 10:20:36 +0200 Subject: [PATCH] Properly migrate the existing profiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure that the default profile (including all its generations) are still available after we move it to the user’s home directory --- src/libstore/profiles.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libstore/profiles.cc b/src/libstore/profiles.cc index d695cf795..d185a898c 100644 --- a/src/libstore/profiles.cc +++ b/src/libstore/profiles.cc @@ -305,11 +305,16 @@ Path getDefaultProfile() if (!pathExists(profileLink) || (isLink(profileLink) && readLink(profileLink) == legacyProfile)) { + warn("Migrating the default profile"); replaceSymlink(newProfile, profileLink); - for (auto & oldGen : findGenerations(legacyProfile).first) { - replaceSymlink( - oldGen.path, - newProfile + "/" + std::string(baseNameOf(oldGen.path))); + replaceSymlink(legacyProfile, newProfile); + if (pathExists(legacyProfile)) { + for (auto & oldGen : findGenerations(legacyProfile).first) { + replaceSymlink( + oldGen.path, + dirOf(newProfile) + "/" + + std::string(baseNameOf(oldGen.path))); + } } } return absPath(readLink(profileLink), dirOf(profileLink));