Skip to content

Commit e4a9201

Browse files
mattiagiupponiMalteIwanicki
authored andcommitted
[Fixes GeoNode#10195] Backup and restore procedure is not successful (GeoNode#10196)
* [Fixes GeoNode#10195] Backup and restore procedure is not successful * [Fixes GeoNode#10195] Backup and restore procedure is not successful * [Fixes GeoNode#10195] Backup and restore procedure is not successful * [Fixes GeoNode#10195] Backup and restore procedure is not successful * [Fixes GeoNode#10195] Backup and restore procedure is not successful * [Fixes GeoNode#10195] test fix build
1 parent d2e04bf commit e4a9201

File tree

2 files changed

+36
-30
lines changed

2 files changed

+36
-30
lines changed

geonode/br/management/commands/backup.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,12 @@ def execute_backup(self, **options):
189189

190190
for static_files_folder in static_folders:
191191

192-
# skip dumping of static files of apps not located under LOCAL_ROOT path
192+
# skip dumping of static files of apps not located under PROJECT_ROOT path
193193
# (check to prevent saving files from site-packages in project-template based GeoNode projects)
194-
if getattr(settings, 'LOCAL_ROOT', None) and \
195-
not static_files_folder.startswith(settings.LOCAL_ROOT):
194+
if getattr(settings, 'PROJECT_ROOT', None) and \
195+
not static_files_folder.startswith(settings.PROJECT_ROOT):
196196
print(f"Skipping static directory: {static_files_folder}. "
197-
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
197+
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
198198
continue
199199

200200
static_folder = os.path.join(static_files_folders,
@@ -221,12 +221,12 @@ def execute_backup(self, **options):
221221

222222
for template_files_folder in template_folders:
223223

224-
# skip dumping of template files of apps not located under LOCAL_ROOT path
224+
# skip dumping of template files of apps not located under PROJECT_ROOT path
225225
# (check to prevent saving files from site-packages in project-template based GeoNode projects)
226-
if getattr(settings, 'LOCAL_ROOT', None) and \
227-
not template_files_folder.startswith(settings.LOCAL_ROOT):
226+
if getattr(settings, 'PROJECT_ROOT', None) and \
227+
not template_files_folder.startswith(settings.PROJECT_ROOT):
228228
print(f"Skipping template directory: {template_files_folder}. "
229-
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
229+
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
230230
continue
231231

232232
template_folder = os.path.join(template_files_folders,
@@ -246,12 +246,12 @@ def execute_backup(self, **options):
246246

247247
for locale_files_folder in locale_folders:
248248

249-
# skip dumping of locale files of apps not located under LOCAL_ROOT path
249+
# skip dumping of locale files of apps not located under PROJECT_ROOT path
250250
# (check to prevent saving files from site-packages in project-template based GeoNode projects)
251-
if getattr(settings, 'LOCAL_ROOT', None) and \
252-
not locale_files_folder.startswith(settings.LOCAL_ROOT):
251+
if getattr(settings, 'PROJECT_ROOT', None) and \
252+
not locale_files_folder.startswith(settings.PROJECT_ROOT):
253253
logger.info(f"Skipping locale directory: {locale_files_folder}. "
254-
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
254+
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
255255
continue
256256

257257
locale_folder = os.path.join(locale_files_folders,

geonode/br/management/commands/restore.py

+24-18
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,20 @@ def execute_restore(self, **options):
274274
print(f"[Sanity Check] Full Write Access to '{static_root}' ...")
275275
chmod_tree(static_root)
276276
for static_files_folder in static_folders:
277-
print(f"[Sanity Check] Full Write Access to '{static_files_folder}' ...")
278-
chmod_tree(static_files_folder)
277+
if getattr(settings, 'PROJECT_ROOT', None) and \
278+
static_files_folder.startswith(settings.PROJECT_ROOT):
279+
print(f"[Sanity Check] Full Write Access to '{static_files_folder}' ...")
280+
chmod_tree(static_files_folder)
279281
for template_files_folder in template_folders:
280-
print(f"[Sanity Check] Full Write Access to '{template_files_folder}' ...")
281-
chmod_tree(template_files_folder)
282+
if getattr(settings, 'PROJECT_ROOT', None) and \
283+
template_files_folder.startswith(settings.PROJECT_ROOT):
284+
print(f"[Sanity Check] Full Write Access to '{template_files_folder}' ...")
285+
chmod_tree(template_files_folder)
282286
for locale_files_folder in locale_folders:
283-
print(f"[Sanity Check] Full Write Access to '{locale_files_folder}' ...")
284-
chmod_tree(locale_files_folder)
287+
if getattr(settings, 'PROJECT_ROOT', None) and \
288+
locale_files_folder.startswith(settings.PROJECT_ROOT):
289+
print(f"[Sanity Check] Full Write Access to '{locale_files_folder}' ...")
290+
chmod_tree(locale_files_folder)
285291
except Exception as exception:
286292
if notify:
287293
restore_notification.apply_async(
@@ -400,14 +406,14 @@ def execute_restore(self, **options):
400406
# Restore Static Folders
401407
for static_files_folder in static_folders:
402408

403-
# skip restoration of static files of apps not located under LOCAL_ROOT path
409+
# skip restoration of static files of apps not located under PROJECT_ROOT path
404410
# (check to prevent overriding files from site-packages
405411
# in project-template based GeoNode projects)
406-
if getattr(settings, 'LOCAL_ROOT', None) and \
407-
not static_files_folder.startswith(settings.LOCAL_ROOT):
412+
if getattr(settings, 'PROJECT_ROOT', None) and \
413+
not static_files_folder.startswith(settings.PROJECT_ROOT):
408414
print(
409415
f"Skipping static directory: {static_files_folder}. "
410-
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
416+
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
411417
continue
412418

413419
if config.gs_data_dt_filter[0] is None:
@@ -425,14 +431,14 @@ def execute_restore(self, **options):
425431
# Restore Template Folders
426432
for template_files_folder in template_folders:
427433

428-
# skip restoration of template files of apps not located under LOCAL_ROOT path
434+
# skip restoration of template files of apps not located under PROJECT_ROOT path
429435
# (check to prevent overriding files from site-packages
430436
# in project-template based GeoNode projects)
431-
if getattr(settings, 'LOCAL_ROOT', None) and \
432-
not template_files_folder.startswith(settings.LOCAL_ROOT):
437+
if getattr(settings, 'PROJECT_ROOT', None) and \
438+
not template_files_folder.startswith(settings.PROJECT_ROOT):
433439
print(
434440
f"Skipping template directory: {template_files_folder}. "
435-
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
441+
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
436442
continue
437443

438444
if config.gs_data_dt_filter[0] is None:
@@ -450,14 +456,14 @@ def execute_restore(self, **options):
450456
# Restore Locale Folders
451457
for locale_files_folder in locale_folders:
452458

453-
# skip restoration of locale files of apps not located under LOCAL_ROOT path
459+
# skip restoration of locale files of apps not located under PROJECT_ROOT path
454460
# (check to prevent overriding files from site-packages
455461
# in project-template based GeoNode projects)
456-
if getattr(settings, 'LOCAL_ROOT', None) and \
457-
not locale_files_folder.startswith(settings.LOCAL_ROOT):
462+
if getattr(settings, 'PROJECT_ROOT', None) and \
463+
not locale_files_folder.startswith(settings.PROJECT_ROOT):
458464
print(
459465
f"Skipping locale directory: {locale_files_folder}. "
460-
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
466+
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
461467
continue
462468

463469
if config.gs_data_dt_filter[0] is None:

0 commit comments

Comments
 (0)