Skip to content

Commit 486d01d

Browse files
committed
Rebased
1 parent 3c1eb62 commit 486d01d

File tree

7 files changed

+142
-163
lines changed

7 files changed

+142
-163
lines changed

lib/src/db.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ use std::{
1414
};
1515

1616
use tracing::instrument;
17-
use url::Url;
1817

1918
use crate::{
20-
atoms::IndexAtom,
2119
atomic_url::AtomicUrl,
20+
atoms::IndexAtom,
2221
commit::CommitResponse,
2322
db::val_prop_sub_index::find_in_val_prop_sub_index,
2423
endpoints::{default_endpoints, Endpoint},
@@ -102,7 +101,7 @@ impl Db {
102101
reference_index,
103102
query_index,
104103
prop_val_sub_index,
105-
server_url,
104+
server_url: AtomicUrl::try_from(server_url)?,
106105
watched_queries,
107106
endpoints: default_endpoints(),
108107
on_commit: None,
@@ -191,15 +190,17 @@ impl Db {
191190
}
192191

193192
fn map_sled_item_to_resource(
194-
&self,
195193
item: Result<(sled::IVec, sled::IVec), sled::Error>,
196194
self_url: String,
197195
include_external: bool,
198196
) -> Option<Resource> {
199197
let (subject, resource_bin) = item.expect(DB_CORRUPT_MSG);
200198
let subject: String = String::from_utf8_lossy(&subject).to_string();
201199

202-
if !include_external && self.is_external_subject(&subject).ok()? {
200+
// if !include_external && self.is_external_subject(&subject).ok()? {
201+
// return None;
202+
// }
203+
if !include_external && !subject.starts_with(&self_url) {
203204
return None;
204205
}
205206

@@ -517,10 +518,11 @@ impl Storelike for Db {
517518
) -> Box<dyn std::iter::Iterator<Item = Resource>> {
518519
let self_url = self
519520
.get_self_url()
520-
.expect("No self URL set, is required in DB");
521+
.expect("No self URL set, is required in DB")
522+
.to_string();
521523

522524
let result = self.resources.into_iter().filter_map(move |item| {
523-
Db::map_sled_item_to_resource(self, item, self_url.to_string(), include_external)
525+
Db::map_sled_item_to_resource(item, self_url.clone(), include_external)
524526
});
525527

526528
Box::new(result)

lib/src/db/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{urls, Value};
1+
use crate::{atomic_url::Routes, urls, Value};
22

33
use super::*;
44
use ntest::timeout;

lib/src/store.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22
//! This provides many methods for finding, changing, serializing and parsing Atomic Data.
33
44
use crate::storelike::QueryResult;
5-
use crate::Value;
6-
use crate::{atoms::Atom, storelike::Storelike};
7-
use crate::{
8-
atomic_url::AtomicUrl,
9-
atoms::Atom,
10-
storelike::{ResourceCollection, Storelike},
11-
};
5+
use crate::{atomic_url::AtomicUrl, storelike::Storelike};
126
use crate::{errors::AtomicResult, Resource};
7+
use crate::{Atom, Value};
138
use std::{collections::HashMap, sync::Arc, sync::Mutex};
149

1510
/// The in-memory store of data, containing the Resources, Properties and Classes

server/app_assets/dist/index.js

Lines changed: 126 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/app_assets/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/helpers.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ use actix_web::cookie::Cookie;
44
use actix_web::http::header::{HeaderMap, HeaderValue};
55
use actix_web::http::Uri;
66
use atomic_lib::authentication::AuthValues;
7+
use atomic_lib::Storelike;
78
use percent_encoding::percent_decode_str;
89
use std::str::FromStr;
910

1011
use crate::errors::{AppErrorType, AtomicServerError};
11-
use crate::{appstate::AppState, content_types::ContentType, errors::AtomicServerResult};
12+
use crate::{appstate::AppState, errors::AtomicServerResult};
1213

1314
/// Returns the authentication headers from the request
1415
#[tracing::instrument(skip_all)]
@@ -140,24 +141,6 @@ pub fn get_client_agent(
140141
Ok(Some(for_agent))
141142
}
142143

143-
/// Finds the extension
144-
pub fn try_extension(path: &str) -> Option<(ContentType, &str)> {
145-
let items: Vec<&str> = path.split('.').collect();
146-
if items.len() == 2 {
147-
let path = items[0];
148-
let content_type = match items[1] {
149-
"json" => ContentType::Json,
150-
"jsonld" => ContentType::JsonLd,
151-
"jsonad" => ContentType::JsonAd,
152-
"html" => ContentType::Html,
153-
"ttl" => ContentType::Turtle,
154-
_ => return None,
155-
};
156-
return Some((content_type, path));
157-
}
158-
None
159-
}
160-
161144
fn session_cookie_from_header(header: &HeaderValue) -> Option<String> {
162145
let cookies: Vec<&str> = header.to_str().ok()?.split(';').collect();
163146

server/src/search.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ pub fn get_schema_fields(appstate: &SearchState) -> AtomicServerResult<Fields> {
114114
}
115115

116116
/// Indexes all resources from the store to search.
117+
/// Skips Commits.
117118
/// At this moment does not remove existing index.
118119
pub fn add_all_resources(search_state: &SearchState, store: &Db) -> AtomicServerResult<()> {
119120
let resources = store

0 commit comments

Comments
 (0)