Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions server/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,17 @@ pub const BUILT_IN_LIBS: &[&str] = &["string", "re", "difflib", "textwrap", "un
"pipes", "smtpd", "sndhdr", "spwd", "sunau", "telnetlib", "uu", "xdrlib", "struct", "codecs"];

pub const CONFIG_WIKI_URL: &str = "https://github.com/odoo/odoo-ls/wiki/Configuration-files";

use std::sync::LazyLock;

/// True if the minor part of EXTENSION_VERSION is even, false otherwise.
pub static IS_RELEASE: LazyLock<bool> = LazyLock::new(|| {
let parts: Vec<&str> = EXTENSION_VERSION.split('.').collect();
if parts.len() < 2 {
return false;
}
if let Ok(minor) = parts[1].parse::<u32>() {
return minor % 2 == 0;
}
false
});
8 changes: 5 additions & 3 deletions server/src/core/entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{cell::RefCell, cmp, collections::HashMap, path::PathBuf, rc::{Rc, Weak
use tracing::{error, info, warn};
use weak_table::PtrWeakHashSet;

use crate::{constants::{flatten_tree, BuildSteps, OYarn, PackageType, SymType, Tree}, threads::SessionInfo, utils::PathSanitizer};
use crate::{constants::{flatten_tree, BuildSteps, OYarn, PackageType, SymType, Tree}, threads::SessionInfo, utils::PathSanitizer, warn_or_panic};

use super::{odoo::SyncOdoo, symbols::symbol::Symbol};

Expand Down Expand Up @@ -179,10 +179,12 @@ impl EntryPointMgr {
if file_path.ends_with("__manifest__.py") {
warn!("new custom entry point for manifest without related init.py is not supported outside of main entry point. skipping...");
session.sync_odoo.entry_point_mgr.borrow_mut().remove_entries_with_path(tree_path);
return false;
} else {
panic!("Trying to create a custom entrypoint on a namespace symbol: {:?}", new_sym.borrow().paths());
// There was an __init__.py, that was renamed or deleted.
// Another notification will come for the deletion of the file, so we just warn here.
warn_or_panic!("Trying to create a custom entrypoint on a namespace symbol: {:?}", new_sym.borrow().paths());
}
return false;
}
_ => {panic!("Unexpected symbol type: {:?}", new_sym_typ);}
}
Expand Down
11 changes: 11 additions & 0 deletions server/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,14 @@ pub fn is_python_path(path: &String) -> bool {
}
}

#[macro_export]
macro_rules! warn_or_panic {
($($arg:tt)*) => {
if *crate::constants::IS_RELEASE {
let bt = std::backtrace::Backtrace::force_capture();
tracing::warn!("{}\nBacktrace:\n{:?}", format!($($arg)*), bt);
} else {
panic!($($arg)*);
}
}
}