epics-modules / autosave

APS BCDA synApps module: autosave
https://epics-modules.github.io/autosave/
Other
8 stars 31 forks source link

Bad error message if autosave detects a time drift when saving #58

Open simon-ess opened 6 months ago

simon-ess commented 6 months ago

If the time on the filesystem hosting the autosave files differs from the IOC clock, then you get some incorrect error messages:

2024-02-15 15:28:49 save_restore:write_save_file: Can't write save file. [240215-152849]
2024-02-15 15:28:49 save_restore:write_it: file time is different from IOC time [240215-152849], difference=7050.000000s

This is incorrect as the files are actually saved just fine: the problem is that the write_it does the following:

    delta_time = difftime(time(NULL), fileStat.st_mtime);
    if (delta_time > 10.0) {
        printf("save_restore:write_it: file time is different from IOC time [%s], difference=%fs\n",
            datetime, delta_time);
        return(ERROR);
    }

Note the return (ERROR):

    if (write_it(save_file, plist) == ERROR) {
        printf("*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n");
        printf("save_restore:write_save_file: Can't write save file. [%s]\n", datetime);
        printf("*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n");

This means that the file can save correctly, but it reports it as if it did not. The message should probably be updated, or the time difference reduced to a warning or something similar.