Lymkwi / python-minetest

A python library to manipulate minetest's files
6 stars 3 forks source link

empty_map doesn't work? #9

Closed ghost closed 8 years ago

ghost commented 8 years ago

this doesn't empty the map: https://gist.github.com/bobombolo/e2f8ae06b9750ecde067015e54bc3c3b I assume I'm using it wrong also, if I use empty_map in a script, the map.sqlite stays locked for anything I try to do afterwards...

Lymkwi commented 8 years ago

the map.sqlite stays locked for anything I try to do afterwards...

If you try to do something from another program while the library is still open in your cleaning script, it will be locked : SQLite locks a database when it opens it to avoid multiple programs writing and reading in the same file, increasing the odds of corrupting it.

You're also trying to open twice the database. A MapInterface will open a MapVessel on the database, which is a different object interacting with it. If you do your modifications on the first object but save in the second nothing will be saved.

ghost commented 8 years ago

That was another question, Should I be creating a Mapinterface and then doing anything that I would otherwise do with a MapVessel through the MapInterface->MapVessel? I think that is why the lock issue is happening... (no other program was touching the sqlite file)

ghost commented 8 years ago

got it:

    map_interface = libminetest.map.MapInterface(dbfile)
    map_interface.set_maxcachesize(241)
    map_interface.container.empty_map()