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

'backup_date' does not backup if there's no previous backup and origin file timestamp is today #10

Open
reisfe opened this issue Dec 30, 2021 · 1 comment

Comments

@reisfe
Copy link

reisfe commented Dec 30, 2021

Issue

Function backup_date() does not create the backup under the following conditions:

  1. there's no previous backup made;
  2. timestamp of file to be backed up is the same as the one when we try to make the backup;

Diagnostic

The issue seems to be caused by code in 'DirectoryQueue.R', function/method should_rotate(), line 601. In case there's no backup, self$last_rotation returns NULL and the following line of code

if (is.null(last_rotation))
        return(TRUE)

seems to indicate that the intended behavior is to create backup in such case.
However, the code in line 601:
last_rotation = self$last_rotation %||% file.info(self$origin)$ctime
results that last_rotation assumes the value of the timestamp of the file to be backed up and if that date is the same of the current day then the backup is never made. The code in line 601 makes me doubt what is in fact the intended behavior under the conditions listed above.

Suggestion

In my opinion, under those conditions the backup should be made.

@s-fleck
Copy link
Owner

s-fleck commented Dec 30, 2021

Thanks for the report. I vaguely remember looking into that behaviour and not coming to a better solution.

The behaviour is the way it is because backup and rotate should behave consistently, and for rotate it makes much more sense to do it the way it is now. (rotate is also the main function of the package, and backup is just a "free" extra).

I understand how this might be slightly confusing, and I'll look into it again when I get the chance (maybe an additional argument), but I'm not sure I'll come up with something :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants