[Merged] PR#1148: Backup files policy

Merged, abandoned or rejected pull requests are moved here to clear the main Pull Requests forum.
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: PR#1148: Backup files policy

Post by chrisb »

plgarcia wrote: Fri Feb 23, 2018 6:25 pm Yes it is the way, but I am spending quite some time on colors management, and I would like to finish that before investing in more areas.

And anyway, no use to develop without having some kind of agreement on what to do if we want to have a chance to have the change accepted and integrated in the software.
Each of these arguments is, of course, fully accepted.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
plgarcia
Posts: 310
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: PR#1148: Backup files policy

Post by plgarcia »

yorikvanhavre wrote: I prefer the way backup files are now, it keeps things much cleaner IMHO. My opinion is that if you want to implement this, it should be optional and not mandatory.
OK there are two things in the PR.
  • Everything around solving issues:
    • Maintaining the right number of archives when changing the configuration
    • Reporting to the user when a problem occurs
  • Changing the naming policy of the backups.
I will make the naming policy selectable. I have to think about that.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: PR#1148: Backup files policy

Post by triplus »

Hi @plgarcia

As for observation from @chrisb i am not sure if i understand the issue.

Code: Select all

ls -t
Should work in the same way?

I see there is some consensus gathered around using .FCBak extension. That is an improvement. As for suggestions to make it more complex or to let user decide. That likely indicates it makes more sense to tackle this in FreeCAD 0.18 development cycle. And to try to build more consensus around it first. Hopefully to result in something simple, making sense and enabled for all.
plgarcia
Posts: 310
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: PR#1148: Backup files policy

Post by plgarcia »

Everything is coded and tested in document.cpp. Last changes not pushed.
Selecting is done by a bool I set to true or false to select the old name or the new.

The only thing left is to add this selector in the configuration pannel.
What label, where on the pannel etc?
plgarcia
Posts: 310
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: PR#1148: Backup files policy

Post by plgarcia »

Is this way selecting and the label acceptable ?
It is also possible to add the date formart set by default to %Y%m%d-%H%M%S
Capture9.PNG
Capture9.PNG (130.55 KiB) Viewed 3824 times
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: PR#1148: Backup files policy

Post by chrisb »

plgarcia wrote: Sun Feb 25, 2018 6:41 pm It is also possible to add the date formart set by default to %Y%m%d-%H%M%S
I would like to see the placeholders included. That makes it easier to include more of them in the future.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
plgarcia
Posts: 310
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: PR#1148: Backup files policy

Post by plgarcia »

The problem that should be address before implementing more complex things is to clearly identify the backups.

In order to be certain to identify that the archives concern the document we are saving, I check
  • For the FCBack extension:
    • the presence of the base name + “.”,
    • the extension and
    • the length of what is in between that must the length of a date
  • for the old fashion, I check
    • the presence of the full name with extension,
    • and the length of what follows that must be 1 or 2 (1 to 99)
These checks ensure that the file is not that main file of another project, and unless the user has changed the name of the archive, that it is an archive of this project.
I am able to manage both formats, and even if the format is changed during the life of the project, the n latest backups and only these backups will be kept.
Before we implement things more complex, we must define how we will identify the backups. It would be a real problem if we remove backups of a different project, and even worse the main file itself!

I will incorporate the format of the date as a start.

Here is the change:
Capture10.PNG
Capture10.PNG (126.24 KiB) Viewed 3798 times
Commit done
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: PR#1148: Backup files policy

Post by triplus »

I noticed a typo (FCBack instead of FCBak).

What happens if user for example removes the %S and saves a file in a few seconds interval. Wouldn't that result in the need to check again if the backup file (name) already exists. And if it does. To add some for example incremental number to the backup file name? ;)
plgarcia
Posts: 310
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: PR#1148: Backup files policy

Post by plgarcia »

In this case a -1 -2 up to 99 is added to the date before the extension, until a name not used is found.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: PR#1148: Backup files policy

Post by triplus »

I see. Well you i guess did satisfy all the requirements and different views expressed. Hopefully no regression was introduced in this area. From FreeCAD 0.17 point of view. That is if PR will be merged before FreeCAD 0.18 development cycle starts.
Post Reply