Giter Club home page Giter Club logo

Comments (3)

sysnux avatar sysnux commented on July 19, 2024

So I have been able to update a dataset by changing:

diff --git a/importer/handlers/common/vector.py b/importer/handlers/common/vector.py
index 3a56e16..a26a2b3 100644
--- a/importer/handlers/common/vector.py
+++ b/importer/handlers/common/vector.py
@@ -356,9 +356,7 @@ class BaseVectorFileHandler(BaseHandler):
 
         dataset_exists = dataset_available.exists()
 
-        if dataset_exists and should_be_overwritten:
-            alternate = dataset_available.first().alternate
-        elif not dataset_exists:
+        if not dataset_exists or dataset_exists and should_be_overwritten:
             alternate = layer_name
         else:
             alternate = create_alternate(layer_name, str(_exec_obj.exec_id))

Works for me, but I'm new to GeoNode development, and I'd appreciate to have a comment from someone who knows better.

from geonode-importer.

mattiagiupponi avatar mattiagiupponi commented on July 19, 2024

Hi @sysnux
To overwrite an existing layer is enough to call the upload API by passing the override_existing_layer=True as an additional parameter.
NOTE: be sure that the layer name you are providing matches the alternate that was generated (if is the only dataset available will have the layer_name=alternate), otherwise if you have multiple layers with the same name the system will append a MD5 to make it unique.

For example:

  • layer_name = stations
  • Does not exist a dataset with the alternate workspace:layer_name -> layer_name / alternate => stations
  • Exists a dataset with the alternate workspace:layer_name -> layer_name / alternate => stations / stations_018735210827d5063ed0a1

So you want to overwrite the second layer, the layer name provided must match stations_018735210827d5063ed0a1

With your change, you are risking overwriting an unwanted layer. Two layers can have the same name but have different data in them.

Can you please try to roll back the changes and follow the above point to see if it works?
Thanks

from geonode-importer.

mattiagiupponi avatar mattiagiupponi commented on July 19, 2024

i'll close due the lack of feedback

from geonode-importer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.