From 3b16063a827fc22cc3084cc6fa0bcf8936624136 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Tue, 26 Feb 2019 00:33:35 +0100 Subject: [PATCH 1/8] [fix] Copy only app missing in new apps dir --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index d58f4b0..57add37 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -205,6 +205,7 @@ do # Backup 3rd party applications from the current nextcloud # But do not overwrite if there is any upgrade # (apps directory already exists in Nextcloud archive) + touch -t 197001010000 $final_path/apps/* cp -a --update "$final_path/apps" "$tmpdir" # Replace the old nextcloud by the new one From c71a444a946751fd658a4bb25841b617870d3fc4 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 26 Feb 2019 00:57:24 +0100 Subject: [PATCH 2/8] [fix] Use the old owncloud method to copy apps dir --- scripts/upgrade | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 57add37..06ea0ff 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,7 +49,7 @@ fi current_version=$(grep OC_VersionString "$final_path/version.php" | cut -d\' -f2) current_major_version=${current_version%%.*} -if [ $current_major_version -gt 11 ] +if [ $current_major_version -gt 15 ] then # Inform the backup/restore process that it should not save the data directory ynh_app_setting_set $app backup_core_only 1 @@ -205,8 +205,10 @@ do # Backup 3rd party applications from the current nextcloud # But do not overwrite if there is any upgrade # (apps directory already exists in Nextcloud archive) - touch -t 197001010000 $final_path/apps/* - cp -a --update "$final_path/apps" "$tmpdir" + for nc_app_dir in $(sudo ls "${final_path}/apps"); do + [[ ! -d "${tmpdir}/apps/${nc_app_dir}" ]] \ + && cp -a "${final_path}/apps/${nc_app_dir}" "${tmpdir}/apps/${nc_app_dir}" + done # Replace the old nextcloud by the new one ynh_secure_remove "$final_path" From 15f6eb637f7d413906ae4e149c6313c6226b4ef9 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Tue, 26 Feb 2019 00:58:36 +0100 Subject: [PATCH 3/8] [fix] Reset backup on 12 and later version --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 06ea0ff..2d54c82 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,7 +49,7 @@ fi current_version=$(grep OC_VersionString "$final_path/version.php" | cut -d\' -f2) current_major_version=${current_version%%.*} -if [ $current_major_version -gt 15 ] +if [ $current_major_version -gt 11 ] then # Inform the backup/restore process that it should not save the data directory ynh_app_setting_set $app backup_core_only 1 From 8bee85518de978e41cec1456dbeb8ac0978708df Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Thu, 28 Feb 2019 18:05:10 +0100 Subject: [PATCH 4/8] [enh] Remove sudo and double brackets --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2d54c82..e83811c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -205,8 +205,8 @@ do # Backup 3rd party applications from the current nextcloud # But do not overwrite if there is any upgrade # (apps directory already exists in Nextcloud archive) - for nc_app_dir in $(sudo ls "${final_path}/apps"); do - [[ ! -d "${tmpdir}/apps/${nc_app_dir}" ]] \ + for nc_app_dir in $(ls "${final_path}/apps"); do + [ ! -d "${tmpdir}/apps/${nc_app_dir}" ] \ && cp -a "${final_path}/apps/${nc_app_dir}" "${tmpdir}/apps/${nc_app_dir}" done From 567e54289aedcc545d4e4732678e433cbbecf1a6 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 7 Mar 2019 12:04:27 +0100 Subject: [PATCH 5/8] Keep the code clear and simple... --- scripts/upgrade | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index e83811c..16e3a74 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -205,9 +205,12 @@ do # Backup 3rd party applications from the current nextcloud # But do not overwrite if there is any upgrade # (apps directory already exists in Nextcloud archive) - for nc_app_dir in $(ls "${final_path}/apps"); do - [ ! -d "${tmpdir}/apps/${nc_app_dir}" ] \ - && cp -a "${final_path}/apps/${nc_app_dir}" "${tmpdir}/apps/${nc_app_dir}" + for nc_app_dir in "$(ls "$final_path/apps")" + do + if [ ! -d "$tmpdir/apps/$nc_app_dir" ] + then + cp -a "$final_path/apps/$nc_app_dir" "$tmpdir/apps/$nc_app_dir" + fi done # Replace the old nextcloud by the new one From e8349d8dc9d919e7577deaf06364f54bb0e14e14 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sun, 17 Mar 2019 12:43:11 +0100 Subject: [PATCH 6/8] Fix apps directory parsing --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 16e3a74..ef3e1e0 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -206,6 +206,7 @@ do # But do not overwrite if there is any upgrade # (apps directory already exists in Nextcloud archive) for nc_app_dir in "$(ls "$final_path/apps")" + for nc_app_dir in "$(ls -1 "$final_path/apps")" do if [ ! -d "$tmpdir/apps/$nc_app_dir" ] then From 3e1f3c2bc1dc5cdb2ae4ce0e65285f02d740d279 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 17 Mar 2019 12:53:33 +0100 Subject: [PATCH 7/8] Duplicated 'for' --- scripts/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index ef3e1e0..e4a97f3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -205,7 +205,6 @@ do # Backup 3rd party applications from the current nextcloud # But do not overwrite if there is any upgrade # (apps directory already exists in Nextcloud archive) - for nc_app_dir in "$(ls "$final_path/apps")" for nc_app_dir in "$(ls -1 "$final_path/apps")" do if [ ! -d "$tmpdir/apps/$nc_app_dir" ] From 6944dac81a382a2ae9aadd094865a03058442919 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sat, 23 Mar 2019 21:27:02 +0100 Subject: [PATCH 8/8] Fix directory parsing --- scripts/upgrade | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index e4a97f3..774524c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -205,13 +205,16 @@ do # Backup 3rd party applications from the current nextcloud # But do not overwrite if there is any upgrade # (apps directory already exists in Nextcloud archive) - for nc_app_dir in "$(ls -1 "$final_path/apps")" + ( + cd $final_path/apps + for nc_app_dir in */ do - if [ ! -d "$tmpdir/apps/$nc_app_dir" ] - then - cp -a "$final_path/apps/$nc_app_dir" "$tmpdir/apps/$nc_app_dir" - fi + if [ ! -d "$tmpdir/apps/$nc_app_dir" ] + then + cp -a "$nc_app_dir" "$tmpdir/apps/$nc_app_dir" + fi done + ) # Replace the old nextcloud by the new one ynh_secure_remove "$final_path"