Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataSourceClient.deleteDataStore() can't delete the origin file in disk #53

Open
simonscat-123 opened this issue Dec 13, 2021 · 4 comments

Comments

@simonscat-123
Copy link

Hello!This is a great project and it inspirited me a lot. But some method may not seem to work as I expected.
When I use dataSourceClient.deleteDataStore(), I want to delete both the store in geoserver and origin file in disk:
const source2 = dataSource.deleteCoverageStore('testAuto', 'testCN', true)
After code runs, it returned status 200 and statusText 'OK', and the store can't be found in geoserver as well. But when I checked the disk, I found that the origin file was still in there. I also checked the Rest API Document, I think setting 'recurse = true' could delete the origin file, but it just doesn't.
Is this a bug in geoserver? What is the difference between 'purge' and 'recurse'?
Thanks for the answer!

@JakobMiksch
Copy link
Contributor

Hi @simonscat-123 Thanks for your feedback.
I guess for deleting the file on the disk you need to provide the parameter purge=all in the Request. See the screenshot of the docs below.

Currently in geoserver-node-client only the recurse parameter is implemented, but not the purge parameter.

Adding the purge parameter should be relatively easy. The respective code is here: https://github.com/meggsimum/geoserver-node-client/blob/master/src/datastore.js#L495-L507

A pull request for this issue is very appreciated. Let me know if you have further questions.

image

@simonscat-123
Copy link
Author

simonscat-123 commented Dec 14, 2021

Thanks for the reply! @JakobMiksch
After a day of learning and trying, I found that no matter how the purge is set, it can't delete the files on the dist, even if the status is 200. I don’t know if this is just my problem . But I found other ways to solve my needs, which requires some extensions to the code.

I have thousands of remote sensing images that need to be published on geoserver, and the layer styles need to be set as appropriate. At first I tried to use DatastoreClient.createGeotiffFromFile() to do the publishing, but I found that it would make a copy of all the original files into /data/(workspaceName)/(coverageStoreName)/. This definitely cost a lot extra disk space. Then I tried using DatastoreClient.deleteCoverageStore() to delete them, but no matter how I set the parameters, I couldn't delete the copied or original files.

Then after carefully studying your code and the Geoserver Rest API, I decided to create new method createCoverageStore which rely on the API:
https://docs.geoserver.org/latest/en/api/#1.0.0/coveragestores.yaml
image
to create geotiff coverageStore without additional disk space cost. and create another new method createCoverage which rely on the API:
https://docs.geoserver.org/latest/en/api/#1.0.0/coverages.yaml
image
to create geotiff coverage. Then use StyleClient().assignStyleToLayer to set the style individually.

In fact, the configuration body of coverageStore and coverage is complex (as long as the API example), but also flexible. I am not sure if it is appropriate to add these to the project. If there is anything I can do, please let me know 😃

@chrismayer
Copy link
Collaborator

Hi @simonscat-123, sounds good. Would you like to create a pull request offering the 2 new functions you described in your comment above? Would be very appreciated.

@simonscat-123
Copy link
Author

@chrismayer Sure, I will finish it in a few days.

@JakobMiksch JakobMiksch changed the title dataSourceClient.deleteDataStore() can't delete the origin file in disk dataSourceClient.deleteDataStore() can't delete the origin file in disk Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants