scripting files get deleted when a map is resaved

Bug #1375915 reported by wl-zocker
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Critical
Unassigned

Bug Description

Steps to reproduce:
- Make sure the option "Do not zip Widelands data files" is selected.
- Create a map and save it.
- In the map's folder, place some files (an empty init.lua is enough).
- Go to the editor, open the map and save it under the same name.

Expected result: The scripting files remain untouched.

Actual result: The scripting folder is empty.

This is quite frustrating when the whole scripting (maybe hours of work) are gone and there is no backup.

This only happens when the files are not zipped. If zipped (and unpacked/packed manually), the scripting files are not deleted.
Tested on Win7 and Ubuntu 14.04 with r7194.

Related branches

Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Thanks for reporting. I can confirm the same behaviour here with r7194, but I'm not sure why it does that.

Btw, I have wondered for a rather long time why it is possible to save maps/savegames/etc as a directory or a zip file. (And well, since we have been cleaning up the source code and removing various things, are both ways still needed?)

Changed in widelands:
importance: Undecided → Medium
status: New → Confirmed
tags: added: editor lua
Revision history for this message
wl-zocker (wl-zocker) wrote :

Until recently, I did not care much how my data are saved, and I let it as zip files (the default, I think). While I do not know whether it makes sense to modify savegames, having non-zipped map files makes scripting changes easier. I am glad we have this option, although it might seem a bit strange.

Revision history for this message
SirVer (sirver) wrote :

That is definitively a regression (or something that does not happen on Mac). I used to develop campaigns with using the nozip option and the scripts were definitively not deleted.

tags: added: regression
Changed in widelands:
importance: Medium → High
milestone: none → build19-rc1
Revision history for this message
Mirian Margiani (millimarg) wrote :

It might be interesting that this only happens if you overwrite the existing directory. If you save the map elsewhere, all scripting files get saved.

SirVer (sirver)
Changed in widelands:
importance: High → Critical
Revision history for this message
meitis (meitis) wrote :

Hi,

editor/ui_menus/editor_main_menu_save_maps.cc
MainMenuSaveMap::save_map(...)

// Check if file exists. If so, show a warning.
if (g_fs->file_exists(complete_filename)) {
...
 g_fs->fs_unlink(complete_filename);

I guess the solution would be to read the filesystem files and compare the list with the map filesystem? And then add missing files to the map filesystem? Then they will be written to the real file system again. But I am really not familiar with the editor at all. Is it possible to change the lua files in the editor? What happens if you save a map to a directory, then edit the lua file in the editor and in the filesystem? Then you lost... editing files in the filesystem directly is dangerous. Or what should happen if a file exists in the map filesytem and was also already saved to the real filesystem? If it is now changed in the real filesystem, how to determine which version to take?

I think this is problematic. Adding new files is no big deal, anything on top seems dangerous to me.

Maybe it would be a solution to check wether the file in the filesystem changed. If so, issue a warning. I think the approach should be not to edit files in the filesystem. If you want to do that, close the editor, edit the file, open the editor again. (or just close the map in the editor and open it again). New files could be handled though.

Please advice, I can implement it.

best regards
Paul

Revision history for this message
wl-zocker (wl-zocker) wrote :

#5: I'm sorry, I don't understand your filesystems :(

But:
AFAIK, it's not possible to change the scripting files from inside Widelands (Editor). I have always done that via an external text editor. As long as this system doesn't change, the rule is simple: Do not touch the scripting folder, including its subdirectories.

Revision history for this message
meitis (meitis) wrote :

nevermind, that was not really correct anyway :)

but I fixed the bug

there is just one usecase that needs to be discussed:

if you have a existing map directory with scripts and create a completely new map in the editor and save that new map into the map directory with scripts, you will loose the scripts currently.

if you create a new map, save it to (a new or existing) directory, place scripts files there, and then save and save again, its all right, the files remain there.

also of course if you load a map directory with (or without scripts), the scripts stay as they are

GunChleoc (gunchleoc)
Changed in widelands:
status: Confirmed → Fix Committed
GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → Fix Released
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build19-rc1.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.