Open Pheidologeton opened 2 years ago
The person at #318 had the right idea: find should take -maxdepth 1
switch and search for the recovery dirs with the right prefix, i.e. all usages of find should change like
-find "${DIR%/*}" -type d -name '*crashrecovery*' -print0
+find "${DIR%/*}" -maxdepth 1 -type d -name "${DIR##*/}-backup-crashrecovery-*" -print0
This drastically reduces I/O and makes the rm -rf
safer, when the backup dir happens to be in $HOME.
@albel727 - thanks for pointing that out. Can you please try the latest commit and report back. Seems to work for me with limited testing. Would be nice if someone could test with firefox/multiple profiles.
I see your latest commit, but I can't test it at this time. I can only say, that I've been running similarly patched version myself and it worked for me too.
The only problem with this commit as it is, is that it worsens another bug, which was mentioned in #318 too. Namely that enforce()
forgets to call load_env_for $browser
and set the $DIR
variable and hence uses some random $DIR
, that happened to stuck from some previously invoked function. It almost didn't matter before, because *crashrecovery*
pattern was sloppy enough to find most backup dirs anyway. But with the new exact search this is no longer the case and so it will lead to most backup dirs no longer getting removed.
This is easy to fix by just adding the correct load_env_for
with a loop over $DIRArr
or even by unifying enforce()
and cleanup()
(the latter is basically the former with $BACKUP_LIMIT = 0
).
Compare the wrong code in enforce()
https://github.com/graysky2/profile-sync-daemon/blob/9491a03303f85ed31d781e962d82583ade77cacc/common/profile-sync-daemon.in#L589-L590
with the correct code in cleanup()
https://github.com/graysky2/profile-sync-daemon/blob/9491a03303f85ed31d781e962d82583ade77cacc/common/profile-sync-daemon.in#L363-L368
I have disabled crashrecovery in psd.conf, but psd still calls find to find crashrecovery in the home folder. Since I have a lot of small files (40+ million) in /home/user, this takes a long time and causes a lot of i/o.