Skip to content

Commit d003a9d

Browse files
committed
Fix initial indexing bug #560
1 parent ccd3638 commit d003a9d

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ See [STATUS.md](server/STATUS.md) to learn more about which features will remain
1212
- Add `--force` to `atomic-server import` #536
1313
- Fix index issue happening when deleting a single property in a sorted collection #545
1414
- Update JS assets & playwright
15+
- Fix initial indexing bug #560
1516

1617
## [v0.34.0] - 2022-10-31
1718

server/src/appstate.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,9 @@ pub fn init(config: Config) -> AtomicServerResult<AppState> {
5151
store.build_index(true)?;
5252
tracing::info!("Building index finished!");
5353
}
54+
5455
tracing::info!("Setting default agent");
5556
set_default_agent(&config, &store)?;
56-
if config.initialize {
57-
tracing::info!(
58-
"Running initialization commands (first time startup, or you passed --initialize)"
59-
);
60-
store.populate()?;
61-
set_up_initial_invite(&store)
62-
.map_err(|e| format!("Error while setting up initial invite: {}", e))?;
63-
// This means that editing the .env does _not_ grant you the rights to edit the Drive.
64-
tracing::info!("Setting rights to Drive {}", store.get_server_url());
65-
}
6657

6758
// Initialize search constructs
6859
tracing::info!("Starting search service");
@@ -87,6 +78,18 @@ pub fn init(config: Config) -> AtomicServerResult<AppState> {
8778
};
8879
store.set_handle_commit(Box::new(send_commit));
8980

81+
if config.initialize {
82+
tracing::info!(
83+
"Running initialization commands (first time startup, or you passed --initialize)"
84+
);
85+
store.populate()?;
86+
87+
set_up_initial_invite(&store)
88+
.map_err(|e| format!("Error while setting up initial invite: {}", e))?;
89+
// This means that editing the .env does _not_ grant you the rights to edit the Drive.
90+
tracing::info!("Setting rights to Drive {}", store.get_server_url());
91+
}
92+
9093
Ok(AppState {
9194
store,
9295
config,

server/src/search.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,19 @@ pub fn get_schema_fields(appstate: &SearchState) -> AtomicServerResult<Fields> {
116116
/// Indexes all resources from the store to search.
117117
/// At this moment does not remove existing index.
118118
pub fn add_all_resources(search_state: &SearchState, store: &Db) -> AtomicServerResult<()> {
119+
tracing::info!("Building search index...");
120+
119121
let resources = store
120122
.all_resources(true)
121123
.filter(|resource| !resource.get_subject().contains("/commits/"));
122124

123125
for resource in resources {
126+
println!("Indexing {}", resource.get_subject());
124127
add_resource(search_state, &resource, store)?;
125128
}
126129

127130
search_state.writer.write()?.commit()?;
131+
tracing::info!("Search index finished!");
128132
Ok(())
129133
}
130134

server/src/serve.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ fn rebuild_index(appstate: &crate::appstate::AppState) -> AtomicServerResult<()>
2626
.write()
2727
.expect("Could not get a lock on search writer")
2828
.delete_all_documents()?;
29-
tracing::info!("Building search index...");
3029
crate::search::add_all_resources(&appstate_clone.search_state, &appstate.store)?;
31-
tracing::info!("Search index finished!");
3230
Ok(())
3331
}
3432

0 commit comments

Comments
 (0)