Skip to content

Commit

Permalink
[FIX] addons install/update/uninstall with non-existing logfile
Browse files Browse the repository at this point in the history
  • Loading branch information
katyukha committed Oct 5, 2023
1 parent 6aa5e84 commit 67365f2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## Release 0.0.15 (Unreleased)

### Fixes

- Fix error when running `addons install/update/uninstall` with non-existing
logfile. This was caused by attempt to determine starting point of logfile
to search for errors happened during operation.
Now this case is handled correctly.

## Release 0.0.14 (2023-10-04)

### Added
Expand Down
23 changes: 20 additions & 3 deletions subpackages/cli/source/odood/cli/commands/addons.d
Original file line number Diff line number Diff line change
Expand Up @@ -451,20 +451,37 @@ class CommandAddonsUpdateInstallUninstall: OdoodCommand {
start_again=true;
}

auto log_file = project.odoo.logfile.openFile("rt");
File log_file;
if (project.odoo.logfile.exists)
// Open file only if file exists
log_file = project.odoo.logfile.openFile("rt");

bool error = false;
scope(exit) log_file.close();

foreach(db; dbnames) {
auto log_start = log_file.size();
if (!log_file.isOpen && project.odoo.logfile.exists)
// If file is not opened but exists, open it.
// This is needed to correctly compute starting point
// for tracking log messages happened during operation (dg)
log_file.open(project.odoo.logfile.toString, "rt");

auto log_start = log_file.isOpen ? log_file.size() : 0;

try {
// Try to apply delegate
dg(db);
} catch (ServerCommandFailedException e) {
error = true;

if (!log_file.isOpen && project.odoo.logfile.exists)
// If file is not opened but exists, open it.
// This is needed to be able to read log messages
// happeded during execution of dg delegate
log_file.open(project.odoo.logfile.toString, "rt");

// Print errors from logfile to stdout.
if (log_file.size > log_start) {
if (log_file.isOpen && log_file.size > log_start) {
writeln("Following errors detected during install:".red);
log_file.seek(log_start);
foreach(log_line; OdooLogProcessor(log_file))
Expand Down
2 changes: 1 addition & 1 deletion subpackages/lib/source/odood/lib/package.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module odood.lib;

public immutable string _version = "0.0.14";
public immutable string _version = "0.0.15";

public import odood.lib.project;

0 comments on commit 67365f2

Please sign in to comment.