[haiku-commits] Change in haiku[master]: Installer: fix 'clean install' over existing installation.

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 8 Aug 2020 17:26:26 +0000

From Niels Sascha Reedijk <niels.reedijk@xxxxxxxxx>:

Niels Sascha Reedijk has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/3140 ;)


Change subject: Installer: fix 'clean install' over existing installation.
......................................................................

Installer: fix 'clean install' over existing installation.

Whenever the target of an installation is a partition that is not empty, the
Installer prompts the user whether they would like to continue with a 'clean
installation', i.e. an installation that clears out the system folder,
excluding the settings, and cleanly installs the assets in the source's
system folder. At all other locations the source data is merged, meaning that
the source version is copied in place.

The logic that clears out the existing /system/ directory stopped working. This
commit changes the logic in such a way that existing directories under the
/system/ directory will be clobbered (i.e. removed) except for those that are
in /system/settings and below.

Furthermore, there is a change in the logic that makes sure that if the target's
directory was clobbered, that it will be recreated.

The change was manually tested by doing both clean installs and 'upgrades'.

Fixes #16092
---
M src/apps/installer/CopyEngine.cpp
M src/apps/installer/WorkerThread.cpp
2 files changed, 10 insertions(+), 8 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/40/3140/1

diff --git a/src/apps/installer/CopyEngine.cpp 
b/src/apps/installer/CopyEngine.cpp
index e2dab52..ccbd25a 100644
--- a/src/apps/installer/CopyEngine.cpp
+++ b/src/apps/installer/CopyEngine.cpp
@@ -354,13 +354,15 @@
                                        "%s\n", sourcePath.Path(), 
strerror(ret));
                                return ret;
                        }
-               } else {
-                       ret = create_directory(destPath.Path(), 0777);
-                       if (ret != B_OK && ret != B_FILE_EXISTS) {
-                               fprintf(stderr, "Could not create '%s': %s\n", 
destPath.Path(),
-                                       strerror(ret));
-                               return ret;
-                       }
+               }
+
+               ret = create_directory(destPath.Path(), 0777);
+                       // Make sure the target path exists, it may have been 
deleted if
+                       // it was marked as to be clobbered above
+               if (ret != B_OK && ret != B_FILE_EXISTS) {
+                       fprintf(stderr, "Could not create '%s': %s\n", 
destPath.Path(),
+                               strerror(ret));
+                       return ret;
                }

                BDirectory destDirectory(&destination);
diff --git a/src/apps/installer/WorkerThread.cpp 
b/src/apps/installer/WorkerThread.cpp
index 1fd607e..5241915 100644
--- a/src/apps/installer/WorkerThread.cpp
+++ b/src/apps/installer/WorkerThread.cpp
@@ -141,7 +141,7 @@
                const struct stat& statInfo) const
        {
                if (S_ISDIR(statInfo.st_mode) && strncmp("system/", path, 7) == 0
-                               && strcmp("system/settings", path) != 0) {
+                               && strncmp("system/settings", path, 15) != 0 ) {
                        // Replace everything in "system" besides "settings"
                        printf("clobbering '%s'.\n", path);
                        return true;

--
To view, visit https://review.haiku-os.org/c/haiku/+/3140
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: Ia6781c8d2330ba336b3921f9a980b5e31c48a2ec
Gerrit-Change-Number: 3140
Gerrit-PatchSet: 1
Gerrit-Owner: Niels Sascha Reedijk <niels.reedijk@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: Installer: fix 'clean install' over existing installation. - Gerrit