Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cron script of recyclebin delete #55

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -69,9 +69,9 @@ done
# Exit if 'recyclemaxage' is zero.
[ "\${amin}" -eq "0" ] && exit 0
# Exit if another job is running.
if ! mkdir "${lockfile}" &>/dev/null; then
exit 0
fi
[ -e ${lockfile} ] && exit 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial solution has been choosen because mkdir is atomic. With your implementation the creation and checking of the lock file is not atomic anymore because it is splitted into separate operations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem should be solved if the trap is relocated before the mkdir command. I have to check that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With actual solution script never do its work of cleaning recycle because exit always with exit status 0 before, first time creating "lockfile" and after because exist, move trap before delete the "lockfile" on exit but still exit without execute the clean, the only working solution is split create and check "lockfile" (I not know way to make it working without split)

# Create lock
mkdir "${lockfile}" &>/dev/null
# Initialize the trap to cleanup on exit.
trap "rm -rf ${lockfile}; exit" 0 1 2 5 15
# Exit if the recycle bin directory does not exist.
Expand Down