[FIXED] Ticket #4098 - Data loss on close

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Ticket #4098 - Data loss on close

Post by jnxd »

GeneFC wrote: Thu Aug 26, 2021 12:55 pm
jnxd wrote: Thu Aug 26, 2021 4:48 am If one clicks "save anyway", LO will save the file in the same exact path, creating any missing folders.
It seems to me this is the best behavior.
Seems like the best bet. I'll just need to see where I can put the recursive mkdir logic.
It is certainly not standard behavior to change the name of a folder while working on an open file.
Then again that's what testing is for: corner cases.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Ticket #4098 - Data loss on close

Post by GeneFC »

kisolre wrote: Thu Aug 26, 2021 3:27 pm Being easily distracted is not a crime :)
Sorry, I tried to keep my comments neutral to avoid accusing anyone of a "crime". :oops:

Stuff happens.

At the same time I believe almost anyone would agree this is not "standard behavior".

That does not change the need for a proper fix, but in my thinking it does change (reduce) the urgency.

The fix I suggested does not require the program to guess at what the user intended.

Gene
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Ticket #4098 - Data loss on close

Post by TheMarkster »

I think what should happen is FreeCAD should not go ahead and close when there was an error saving the file. In the issue I filed I wasn't renaming folders. For some reason FreeCAD was failing in attempting to rename the temp file to the FCStd file.

https://tracker.freecadweb.org/view.php?id=0004098
When I open that folder I see multiple files in the form of GoProMount.FCStd.long-guid-sequence-of-letters-and-numbers. The project file: GoProMount.FCStd does not contain the latest changes, which instead are (presumably) in the latest guid file.

The workaround for this is to delete all of those files (or just the GoProMount.FCStd file) and try again. No warnings and the file gets updated that way (until I need to save it again). This is only an inconvenience for me because I understand the workaround and how to recover my data, but most users will not understand. Their data is there, but might as well not be there because they won't know.

There is something failing for some reason during this process of creating the temporary guid file and renaming it to the project file.

The worst part of this is if I exit FreeCAD with unsaved changes and elect to save the changes on exit the save fails and yet FreeCAD still exits without any warning message. FreeCAD should not exit. It should remain open so the user can save as the file to another location or at least be told his data is safe in this new guid file, which must be renamed manually.
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Ticket #4098 - Data loss on close

Post by jnxd »

TheMarkster wrote: Thu Aug 26, 2021 6:22 pm I think what should happen is FreeCAD should not go ahead and close when there was an error saving the file. In the issue I filed I wasn't renaming folders. For some reason FreeCAD was failing in attempting to rename the temp file to the FCStd file.
Do you still have the same issue? You mentioned that it wasn't completely reproducible.
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Ticket #4098 - Data loss on close

Post by jnxd »

PR to address this issue: https://github.com/FreeCAD/FreeCAD/pull/4996. Be mindful that the file still closes if saving is aborted. Apparently not: we need to figure out what exactly is supposed to be returned by Gui::Document::save(). I wrongly assumed true if save went through and false otherwise, but it is still true if an exception occurs, and eventually the file closes because of that.

Leaving the PR as a draft for now.
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Ticket #4098 - Data loss on close

Post by TheMarkster »

jnxd wrote: Thu Aug 26, 2021 9:06 pm Do you still have the same issue? You mentioned that it wasn't completely reproducible.
No, it was only with that one file for some reason. Kisolre has found a way that (I haven't tried it) is reproducible -- by renaming the folder the file gets saved to.
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Ticket #4098 - Data loss on close

Post by jnxd »

TheMarkster wrote: Fri Aug 27, 2021 12:02 am
jnxd wrote: Thu Aug 26, 2021 9:06 pm Do you still have the same issue? You mentioned that it wasn't completely reproducible.
No, it was only with that one file for some reason. Kisolre has found a way that (I haven't tried it) is reproducible -- by renaming the folder the file gets saved to.
Oh Kisolre's method is equivalent to the folder being deleted: a folder by the desired name does not exist.
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Ticket #4098 - Data loss on close

Post by jnxd »

I guess I'm done with the PR. Now to wait for people to break it.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Ticket #4098 - Data loss on close

Post by uwestoehr »

jnxd wrote: Sat Aug 28, 2021 1:13 am I guess I'm done with the PR. Now to wait for people to break it.
The PR was merged. Is issue #4098 partially or completely fixed now?
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Ticket #4098 - Data loss on close

Post by jnxd »

uwestoehr wrote: Thu Sep 16, 2021 5:30 pm
jnxd wrote: Sat Aug 28, 2021 1:13 am I guess I'm done with the PR. Now to wait for people to break it.
The PR was merged. Is issue #4098 partially or completely fixed now?
I guess it's pretty much as complete as can be.
Post Reply