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

A corner case handling #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

A corner case handling #4

wants to merge 1 commit into from

Conversation

kumar-mahendra
Copy link

@kumar-mahendra kumar-mahendra commented Feb 13, 2021

It is possible that last modification time of the "target" is after the last modification time of the source file/directory,This can handled by using the inbuilt absolute function abs.

It is possible that last modification time of the "target"  is after the last modification time of the source file/director,This can handled by using the inbuilt absolute function `abs`.
@@ -40,7 +40,7 @@ def size_if_newer(source, target):

# The time difference of one second is necessary since subsecond accuracy
# of os.st_mtime is striped by copy2
return src_stat.st_size if (src_stat.st_mtime - target_ts > 1) else False
return src_stat.st_size if abs(src_stat.st_mtime - target_ts > 1) else False
Copy link
Member

Choose a reason for hiding this comment

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

@kumar-mahendra I think you meant to say the below line :-
return src_stat.st_size if (abs(src_stat.st_mtime - target_ts) > 1) else False

Taking the absolute first and then comparing!

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

Successfully merging this pull request may close these issues.

2 participants