PR#1148: Backup files policy

Post here if you have re-based and finalised code to integrate into master, which was discussed, agreed to and tested in other forums. You can also submit your PR directly on github.
chrisb
Posts: 18038
Joined: Tue Mar 17, 2015 9:14 am

Re: PR#1148: Backup files policy

Post by chrisb » Fri Feb 23, 2018 6:44 pm

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.

plgarcia
Posts: 281
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: PR#1148: Backup files policy

Post by plgarcia » Sat Feb 24, 2018 4:51 pm

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
Posts: 8676
Joined: Mon Dec 12, 2011 4:45 pm

Re: PR#1148: Backup files policy

Post by triplus » Sat Feb 24, 2018 5:24 pm

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: 281
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: PR#1148: Backup files policy

Post by plgarcia » Sat Feb 24, 2018 10:18 pm

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: 281
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: PR#1148: Backup files policy

Post by plgarcia » Sun Feb 25, 2018 6:41 pm

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 616 times

chrisb
Posts: 18038
Joined: Tue Mar 17, 2015 9:14 am

Re: PR#1148: Backup files policy

Post by chrisb » Sun Feb 25, 2018 6:51 pm

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.

plgarcia
Posts: 281
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: PR#1148: Backup files policy

Post by plgarcia » Sun Feb 25, 2018 8:48 pm

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 590 times
Commit done

triplus
Posts: 8676
Joined: Mon Dec 12, 2011 4:45 pm

Re: PR#1148: Backup files policy

Post by triplus » Mon Feb 26, 2018 9:28 pm

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: 281
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: PR#1148: Backup files policy

Post by plgarcia » Mon Feb 26, 2018 10:27 pm

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
Posts: 8676
Joined: Mon Dec 12, 2011 4:45 pm

Re: PR#1148: Backup files policy

Post by triplus » Mon Feb 26, 2018 10:46 pm

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