Bob icon indicating copy to clipboard operation
Bob copied to clipboard

Automatic backup timer not paused when OSX is in sleep mode.

Open petergam opened this issue 10 years ago • 1 comments

The automatic backup timer should be paused when OSX in sleeping.

At the moment the firedate of a backup might happen while the computer is sleeping which will result in a limbo state where automatic backup is not being triggered.

petergam avatar May 12 '14 11:05 petergam

I have come up with a solution for this that is more intelligent than the current. The goal of the solution is to use a very low amount of resources while supported the application being killed or the system sleeping.

Calculate the seconds until the next backup should take place. Subscribe on a signal for when the backup is not executing. Schedule a timer that will signal the value 10 every 10 seconds. Use a reduce on the signal to count down with the start value equal to the number of seconds to the next backup. Use a takeUntilBlock to continue the signal until the value is lower than 0. Subscribe completed on the signal and execute the backup command. Also map the timer to the next estimated backup date. The viewmodel should map this date in order to show when a backup takes place. It will in worth case show that a backup starts 10 seconds too early but we will keep the CPU load low.

The process will automatically loop when the command finishes.

Further schedule a timer to run every 10 minute to persist the value of backup timer signal to the disk. In that case if the application is killed all of a sudden we will still have a pretty fresh value for the timer while keeping the need to write to disk low.

I have prototyped an implementation of this algorithm and it works well. Not ready to be merged yet though.

petergam avatar May 12 '14 22:05 petergam