bit-team / backintime

Back In Time - An easy-to-use backup tool for GNU Linux using rsync in the back
https://backintime.readthedocs.io
GNU General Public License v2.0
1.9k stars 175 forks source link

Global flock active by default (but shouldn't) #1751

Open buhtz opened 3 weeks ago

buhtz commented 3 weeks ago

Context: Bug was introduce by me with PR #1697 providing a new GlobalFlock context manager.

Problem: The check of the config value global.use_flock is gone. So all user will have an activate global flock no matter of the configuration.

Before PR #1697 that global flock was disabled by default config. That config value was queried in a method named flockExclusive(). https://github.com/bit-team/backintime/blob/4d7e920afe18e767a8999cb0752b972b86d5772e/common/snapshots.py#L784

Solution: My proposed solution is to add a new argument to GlobalFlock() context manager to disable it based on the config value global.use_flock. That is not elegant but there is a structure problem with the code in snapshots.py using that context manager. The code block handled by the context manager has hundred of lines of code. Because of that I can not do something like this:

if cfg.globalFlock():
    with flock.GlobalFlock():
        do_the_magic()
else:
    do_the_magic()

I'll combine the solution together with Issue #1743