[Cin] automatic save of

Phyllis Smith phylsmith2017 at gmail.com
Tue Jan 19 03:14:40 CET 2021


Good advice to "test with caution"   ; )  !!

On Mon, Jan 18, 2021 at 7:04 PM Andrew Randrianasulu via Cin <
cin at lists.cinelerra-gg.org> wrote:

> В сообщении от Monday 18 January 2021 13:43:36 Rafa Mar Multimedia en
> Gnu\Linux via Cin написал(а):
> > Thank you very much Reuss András, with the multiple backup copies you
> have
> > done an excellent job, perhaps you could limit these so that you do not
> end
> > up with thousands of copies, with about 50 would be enough.
>
>
> I tried to copy/paste cleanup function, TEST WITH CAUTION!!!!
>
> ======
> void MWindow::clean_backups()
> {
>     FileSystem fs;
>     int total_excess;
>     long oldest = 0;
>     int oldest_item = -1;
>     int result;
>     char string[BCTEXTLEN];
>
> // Delete extra backups
>     fs.set_filter("backup_*.xml");
>     fs.complete_path(preferences->index_directory);
>     fs.update(preferences->index_directory);
>
>     total_excess = fs.dir_list.total - preferences->index_count;
>     printf("Total excess of backups: %i \n", total_excess);
>
> //printf("MWindow::clean_backups 1 %d\n", fs.dir_list.total);
>
>     while(total_excess > 0)
>     {
> // Get oldest
>        for(int i = 0; i < fs.dir_list.total; i++)
>        {
>            fs.join_names(string, preferences->index_directory,
> fs.dir_list[i]->name);
>
>            if(i == 0 || fs.get_date(string) <= oldest)
>            {
>                oldest = fs.get_date(string);
>                oldest_item = i;
>            }
>        }
>
>        if(oldest_item >= 0)
>        {
> // Remove backup file
>            fs.join_names(string,
>                preferences->index_directory,
>                fs.dir_list[oldest_item]->name);
> //printf("MWindow::clean_backups 1 %s\n", string);
>            if(remove(string))
>                perror("delete_backups");
>            delete fs.dir_list[oldest_item];
>            fs.dir_list.remove_number(oldest_item);
>
>        }
>
>        total_excess--;
>     }
> }
>
>
> =====
>
> it clears backups down to same number as max indexes number set in
> Preferences,
> looking for backup_*.xml (note "_" part!!!)
>
> you need to add
>
> diff --git a/cinelerra-5.1/cinelerra/mwindow.h
> b/cinelerra-5.1/cinelerra/mwindow.h
> index 8f9bfbb7..df9fd9db 100644
> --- a/cinelerra-5.1/cinelerra/mwindow.h
> +++ b/cinelerra-5.1/cinelerra/mwindow.h
> @@ -853,6 +853,7 @@ public:
>         int get_cpus();
>  //
>         void clean_indexes();
> +       void clean_backups();
>  //     TimeBomb timebomb;
>         SigHandler *sighandler;
>         int restart_status;
>
> also ...
>
> Ha, remaint of Timebomb :}
>
> Need to be deleted ....
>
> *My* hack for making many_backups was in mwindow.C:
>
> @@ -4276,10 +4369,27 @@ void MWindow::save_backup()
>         edl->optimize();
>         edl->set_path(session->filename);
>
> -       char backup_path[BCTEXTLEN], backup_path1[BCTEXTLEN];
> +       char backup_path[BCTEXTLEN], backup_path1[BCTEXTLEN],
> backup_path2[BCTEXTLEN];
> +
> +       time_t t = time(NULL);
> +        struct tm tm = *localtime(&t);
> +       char BACKUP_FILE2[BCTEXTLEN] ;
> +       sprintf(BACKUP_FILE2, _("backup_%02d%02d%02d-%02d%02d%02d.xml"),
> +           tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
> +           tm.tm_hour, tm.tm_min, tm.tm_sec);
> +
> +       snprintf(backup_path2, sizeof(backup_path2), "%s/%s",
> +               File::get_config_path(), BACKUP_FILE2);
> +
>         snprintf(backup_path1, sizeof(backup_path1), "%s/%s",
>                 File::get_config_path(), BACKUP_FILE1);
>         get_backup_path(backup_path, sizeof(backup_path));
> +
> +       char cmd[1024], *cp = cmd;
> +       cp += sprintf(cp, "cp %s %s &", backup_path, backup_path2);
> +       system(cmd);
> +
> +
>         rename(backup_path, backup_path1);
>         edl->save_xml(&file, backup_path);
>         file.terminate_string();
>
> For Reuss' solution you most likely need to tweak
>
> fs.set_filter("backup_*.xml");
>
> line
>
> ....
>
>
>
> --
> Cin mailing list
> Cin at lists.cinelerra-gg.org
> https://lists.cinelerra-gg.org/mailman/listinfo/cin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20210118/ab257a0e/attachment.htm>


More information about the Cin mailing list