From aff6051e6391c2992c91593f0f874a6ac59fa1c5 Mon Sep 17 00:00:00 2001 From: Dmytro Katyukha Date: Sun, 5 Nov 2023 21:39:02 +0200 Subject: [PATCH] [TMP] Temporary add ability to restore muk filestore if it is packed in backup zip --- subpackages/lib/source/odood/lib/odoo/db_manager.d | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/subpackages/lib/source/odood/lib/odoo/db_manager.d b/subpackages/lib/source/odood/lib/odoo/db_manager.d index 621a28e..e0d24ed 100644 --- a/subpackages/lib/source/odood/lib/odoo/db_manager.d +++ b/subpackages/lib/source/odood/lib/odoo/db_manager.d @@ -350,10 +350,12 @@ struct OdooDatabaseManager { _createEmptyDB(name); auto fs_path = _project.directories.data.join("filestore", name); + auto files_path = _project.directories.data.join("files", name); scope(failure) { // TODO: Use pure SQL to check if db exists and for cleanup if (this.exists(name)) this.drop(name); if (fs_path.exists()) fs_path.remove(); + if (files_path.exists()) files_path.remove(); } // Prepare tasks @@ -394,16 +396,25 @@ struct OdooDatabaseManager { tracef("Restore filestore for database %s", name); auto zip = Zipper(backup_path); fs_path.mkdir(true); + if (zip.hasEntry("files")) files_path.mkdir(true); foreach(entry; zip.entries) { if (entry.name.startsWith("filestore/")) { entry.unzipTo( fs_path.join( entry.name.chompPrefix("filestore/"))); } + if (entry.name.startsWith("files/")) { + entry.unzipTo( + fs_path.join( + entry.name.chompPrefix("files/"))); + } } - if (_project.odoo.server_user) + if (_project.odoo.server_user) { // Set correct ownership for database's filestore fs_path.chown(_project.odoo.server_user); + if (files_path.exists) + files_path.chown(_project.odoo.server_user); + } tracef("Filestore for database %s was successfully restored", name); });