Skip to content

Commit

Permalink
[TMP] Temporary add ability to restore muk filestore if it is packed …
Browse files Browse the repository at this point in the history
…in backup zip
  • Loading branch information
katyukha committed Nov 5, 2023
1 parent f703ac6 commit aff6051
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion subpackages/lib/source/odood/lib/odoo/db_manager.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
});

Expand Down

0 comments on commit aff6051

Please sign in to comment.