geoserver-node-client icon indicating copy to clipboard operation
geoserver-node-client copied to clipboard

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

Open simonscat-123 opened this issue 3 years ago • 4 comments

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!

simonscat-123 avatar Dec 13 '21 02:12 simonscat-123

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

JakobMiksch avatar Dec 13 '21 09:12 JakobMiksch

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 😃

simonscat-123 avatar Dec 14 '21 05:12 simonscat-123

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.

chrismayer avatar Dec 15 '21 10:12 chrismayer

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

simonscat-123 avatar Dec 17 '21 05:12 simonscat-123