Skip to content

Commit

Permalink
Improve check_append error #558
Browse files Browse the repository at this point in the history
  • Loading branch information
joepio committed Feb 4, 2023
1 parent 761360c commit 9284601
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ See [STATUS.md](server/STATUS.md) to learn more about which features will remain
- Fix index issue happening when deleting a single property in a sorted collection #545
- Update JS assets & playwright
- Fix initial indexing bug #560
- Fix errors on succesful export / import #565
- Fix envs for store path, change `ATOMIC_STORE_DIR` to `ATOMIC_DATA_DIR` #567
- Refactor static file asset hosting #578
- Meta tags server side #577
- Include JSON-AD in initial response, speed up first render #511
- Remove feature to index external RDF files and search them #579
- Improve check_append error #558
- Fix errors on successful export / import #565

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

Expand Down
32 changes: 17 additions & 15 deletions lib/src/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,24 @@ pub fn check_append(
resource: &Resource,
for_agent: &str,
) -> AtomicResult<String> {
let parent = if let Ok(parent) = resource.get_parent(store) {
parent
} else {
if resource
.get_classes(store)?
.iter()
.map(|c| c.subject.clone())
.collect::<String>()
.contains(urls::DRIVE)
{
return Ok(String::from("Drive without a parent can be created"));
let parent = match resource.get_parent(store) {
Ok(p) => p,
Err(e) => {
if resource
.get_classes(store)?
.iter()
.map(|c| c.subject.clone())
.collect::<String>()
.contains(urls::DRIVE)
{
return Ok(String::from("Drive without a parent can be created"));
}
return Err(AtomicError::unauthorized(format!(
"Can't append to {} because it's parent cannot be found: {}",
resource.get_subject(),
e
)));
}
return Err(AtomicError::unauthorized(format!(
"No parent found for {}",
resource.get_subject()
)));
};
if let Ok(msg) = check_rights(store, &parent, for_agent, Right::Append) {
Ok(msg)
Expand Down

0 comments on commit 9284601

Please sign in to comment.