mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Prevent parent containers from storing generated metadata
This commit is contained in:
@@ -268,9 +268,7 @@ export class DataAccessorBasedStore implements ResourceStore {
|
||||
deleted.push(container);
|
||||
|
||||
// Update modified date of parent
|
||||
const parentMetadata = await this.accessor.getMetadata(container);
|
||||
updateModifiedDate(parentMetadata);
|
||||
await this.accessor.writeContainer(container, parentMetadata);
|
||||
await this.updateContainerModifiedDate(container);
|
||||
}
|
||||
|
||||
await this.accessor.deleteResource(identifier);
|
||||
@@ -386,15 +384,11 @@ export class DataAccessorBasedStore implements ResourceStore {
|
||||
}
|
||||
|
||||
// Parent container is also modified
|
||||
const parentMetadata = await this.accessor.getMetadata(container);
|
||||
updateModifiedDate(parentMetadata);
|
||||
await this.accessor.writeContainer(container, parentMetadata);
|
||||
await this.updateContainerModifiedDate(container);
|
||||
}
|
||||
|
||||
// Remove all generated metadata to prevent it from being stored permanently
|
||||
representation.metadata.removeQuads(
|
||||
representation.metadata.quads(null, null, null, SOLID_META.terms.ResponseMetadata),
|
||||
);
|
||||
this.removeResponseMetadata(representation.metadata);
|
||||
|
||||
await (isContainer ?
|
||||
this.accessor.writeContainer(identifier, representation.metadata) :
|
||||
@@ -438,6 +432,25 @@ export class DataAccessorBasedStore implements ResourceStore {
|
||||
representation.metadata.addQuads(quads);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all generated data from metadata to prevent it from being stored permanently.
|
||||
*/
|
||||
protected removeResponseMetadata(metadata: RepresentationMetadata): void {
|
||||
metadata.removeQuads(
|
||||
metadata.quads(null, null, null, SOLID_META.terms.ResponseMetadata),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the last modified date of the given container
|
||||
*/
|
||||
protected async updateContainerModifiedDate(container: ResourceIdentifier): Promise<void> {
|
||||
const parentMetadata = await this.accessor.getMetadata(container);
|
||||
updateModifiedDate(parentMetadata);
|
||||
this.removeResponseMetadata(parentMetadata);
|
||||
await this.accessor.writeContainer(container, parentMetadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new URI for a resource in the given container, potentially using the given slug.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user