Skip to content

Commit db9a54e

Browse files
committed
Improve check_append error #558
1 parent a3c2381 commit db9a54e

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ See [STATUS.md](server/STATUS.md) to learn more about which features will remain
3737
- Fix index issue happening when deleting a single property in a sorted collection #545
3838
- Update JS assets & playwright
3939
- Fix initial indexing bug #560
40-
- Fix errors on succesful export / import #565
4140
- Fix envs for store path, change `ATOMIC_STORE_DIR` to `ATOMIC_DATA_DIR` #567
4241
- Refactor static file asset hosting #578
4342
- Meta tags server side #577
4443
- Include JSON-AD in initial response, speed up first render #511
4544
- Remove feature to index external RDF files and search them #579
4645
- Add staging environment #588
4746
- Add systemd instructions to readme #271
47+
- Improve check_append error #558
48+
- Fix errors on successful export / import #565
4849

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

lib/src/hierarchy.rs

+17-15
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,24 @@ pub fn check_append(
6969
resource: &Resource,
7070
for_agent: &str,
7171
) -> AtomicResult<String> {
72-
let parent = if let Ok(parent) = resource.get_parent(store) {
73-
parent
74-
} else {
75-
if resource
76-
.get_classes(store)?
77-
.iter()
78-
.map(|c| c.subject.clone())
79-
.collect::<String>()
80-
.contains(urls::DRIVE)
81-
{
82-
return Ok(String::from("Drive without a parent can be created"));
72+
let parent = match resource.get_parent(store) {
73+
Ok(p) => p,
74+
Err(e) => {
75+
if resource
76+
.get_classes(store)?
77+
.iter()
78+
.map(|c| c.subject.clone())
79+
.collect::<String>()
80+
.contains(urls::DRIVE)
81+
{
82+
return Ok(String::from("Drive without a parent can be created"));
83+
}
84+
return Err(AtomicError::unauthorized(format!(
85+
"Can't append to {} because it's parent cannot be found: {}",
86+
resource.get_subject(),
87+
e
88+
)));
8389
}
84-
return Err(AtomicError::unauthorized(format!(
85-
"No parent found for {}",
86-
resource.get_subject()
87-
)));
8890
};
8991
if let Ok(msg) = check_rights(store, &parent, for_agent, Right::Append) {
9092
Ok(msg)

0 commit comments

Comments
 (0)