[Bug] cannot rename project file to backup file

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!
TheMarkster
Posts: 2078
Joined: Thu Apr 05, 2018 1:53 am

[Bug] cannot rename project file to backup file

Postby TheMarkster » Fri Aug 23, 2019 5:46 pm

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17803 (Git)
Build type: Release
Branch: master
Hash: 89961a33d46063a43e9fb5b0308ca95d559eca94
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)


For some reason the only way I can save the attached file is to first delete it (while it's open in FreeCAD), then save it after deleting. Otherwise saved changes do not get applied.

When I try to save I get this warning in the report view:

Code: Select all

Cannot rename project file to backup file
Cannot rename file from 'C:/Users/mwganson/Downloads/GoProMount.FCStd.723b300a-b1c9-4df4-bba1-aecaf00d0cdb' to 'C:/Users/mwganson/Downloads/GoProMount.FCStd'
I believe when I save the file I get a copy of the one in the message, but with a different guid each time. Presumably, this is the backup file, which contains the saved changes. It is usually then renamed normally, so we don't ever see it. So, if I renamed it and removed the guid it would be good and my data would be safe, but if I didn't know about this I would be totally lost as to how to recover my data. What makes this even more pernicious is if I make changes to the document and exit FreeCAD and answer yes to whether to save changes, the changes don't get saved to the FCstd file and FreeCAD still closes. FreeCAD should not exit if there was a problem saving the file. It should remain open and inform the user there was a problem in saving the file.

With other files I don't have this issue, or at least haven't noticed it with other files.

I have tried deleting my config files -- no change.
I ran a full virus scan -- no problems found.
I ran a full chkdsk /f disk check -- no problems found.
This issue pre-existed the Link merge and thus is unrelated.
I ran as administrator -- no change.

A fix for this could be perhaps to try deleting the file when this exception is caught, then retry renaming. The exception needs to prevent FreeCAD from closing. The user should be informed that a backup exists. Perhaps the backup could contain the FCStd extension at the end of the guid, then users could still open that file without needing to rename it.

I'm not sure why the renaming fails, perhaps because the other file exists and it won't rename the new file over it. Perhaps a delete operation fails and the FCStd file is not any longer supposed to exist at the point of renaming the backup.
Attachments
GoProMount.FCStd
(254.32 KiB) Downloaded 19 times
My FreeCAD video series on youtube: https://www.youtube.com/c/mwganson
User avatar
bejant
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: [Bug] cannot rename project file to backup file

Postby bejant » Fri Aug 23, 2019 7:26 pm

No problem opening and saving the file here, and the .FCStd1 file is created too.

OS: Ubuntu 18.04.2 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.18.1.
Build type: Release
Python version: 3.6.7
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
User avatar
DeepSOIC
Posts: 7841
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: [Bug] cannot rename project file to backup file

Postby DeepSOIC » Fri Aug 23, 2019 10:23 pm

I remember, someone very long ago had a similar problem, caused by cloud sync software. Do you have any enabled on that location?
TheMarkster
Posts: 2078
Joined: Thu Apr 05, 2018 1:53 am

Re: [Bug] cannot rename project file to backup file

Postby TheMarkster » Sat Aug 24, 2019 1:01 am

DeepSOIC wrote: Fri Aug 23, 2019 10:23 pm I remember, someone very long ago had a similar problem, caused by cloud sync software. Do you have any enabled on that location?
I have google drive, which is now called backup and sync or some such, dropbox, and Microsoft's OneDrive installed. Exiting them had no effect. Someone else had this same issue very recently. There was a commit 10 months ago where this warning was added, something to do with backup policy.

I don't know if it's related to the file because if I Save As... and give it another name, e.g. GoProMount2.FCStd, the problem goes away. I'm careful only to add the 2 to end and not retype it all in, and still the problem goes away, but reopen the original and it's 100% reproducible.
My FreeCAD video series on youtube: https://www.youtube.com/c/mwganson
User avatar
DeepSOIC
Posts: 7841
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: [Bug] cannot rename project file to backup file

Postby DeepSOIC » Sat Aug 24, 2019 10:43 am

TheMarkster wrote: Sat Aug 24, 2019 1:01 am I have google drive, ... Exiting them had no effect.
OK, so it's probably not that. But just to be sure, I'd recommend to try it in a location not policed by any synchronizer. Because I think they may be tracking changes even when off, to know, when exactly was a file deleted or renamed.
TheMarkster
Posts: 2078
Joined: Thu Apr 05, 2018 1:53 am

Re: [Bug] cannot rename project file to backup file

Postby TheMarkster » Sat Aug 24, 2019 7:55 pm

Moving the file to another drive, in this case drive e:, solves the issue, but I still don't know why. This folder is not being synchronized. (It is backed up daily to a local drive via backup and restore.)

The larger issue remains: if this happens during exiting the user gets no indication anything went wrong. The data is safe in a file named GoProMount.FCStd.long-guid-digits, but the user has no way of knowing this. FreeCAD should not just quietly exit.
My FreeCAD video series on youtube: https://www.youtube.com/c/mwganson
chrisb
Posts: 34448
Joined: Tue Mar 17, 2015 9:14 am

Re: [Bug] cannot rename project file to backup file

Postby chrisb » Sat Aug 24, 2019 10:58 pm

TheMarkster wrote: Sat Aug 24, 2019 7:55 pm The larger issue remains: if this happens during exiting the user gets no indication anything went wrong. The data is safe in a file named GoProMount.FCStd.long-guid-digits, but the user has no way of knowing this. FreeCAD should not just quietly exit.
That's worth a ticket, at least as a feature request, more likely a bug, as data loss is possible.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
TheMarkster
Posts: 2078
Joined: Thu Apr 05, 2018 1:53 am

Re: [Bug] cannot rename project file to backup file

Postby TheMarkster » Sun Aug 25, 2019 5:43 pm

My FreeCAD video series on youtube: https://www.youtube.com/c/mwganson
User avatar
chennes
Posts: 862
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [Bug] cannot rename project file to backup file

Postby chennes » Sun Feb 07, 2021 11:59 pm

TheMarkster wrote: Sun Aug 25, 2019 5:43 pm issue #4098
git commit d222f7b made some fairly extensive changes to the backup file handling, and was merged a few months after this bug report. I know this was a while ago, but are you still able to replicate? I think the underlying issue still persists (that is, if the copy fails, the quit process just prints the error message and carries on), but I'm not sure about that.
Chris Hennes
Pioneer Library System
chrisb
Posts: 34448
Joined: Tue Mar 17, 2015 9:14 am

Re: [Bug] cannot rename project file to backup file

Postby chrisb » Mon Feb 08, 2021 6:04 am

I have made the following tests: edit a FreeCAD file in a directory whithout write permissions. The FreeCAD file has read/write permissions. Number of backup files to keep is > 0

1)
a) open the file in FreeCAD
b) make changes to the file
c) save the file
d) get a popup alert "Unknown file exception happened", report view says
<Exception> Failed to open file: xxx.FCStd.03d1a0b4-d0f0-47dc-b9ad-237ef48a4516
e) after confirming the alert the file can be saved to a different place

2)
a) as before
b) as before
c) quit FreeCAD and say yes to the saving question
d) same popup and message as above
e) after confirming the dialog FreeCAD exits -> changes are lost
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.