Skip to content

Added preserve_time parameter to move, copy, and mirror #463

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

Merged
merged 17 commits into from
Apr 12, 2021

Conversation

atollk
Copy link
Member

@atollk atollk commented Mar 20, 2021

Type of changes

  • New feature

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @PyFilesystem/maintainers may be pedantic in the code review.

Description

Fixes #450 by adding a preserve_time parameter to all relevant functions. The parameter is False by default to retain previous behaviour. However, it could be argued that the default should be True to mimic more common behavior found in operating systems.

atollk added 4 commits March 20, 2021 17:56
If `preserve_time` is set to True, the call tries to preserve the atime, ctime, and mtime timestamps on the file after the copy. The value is currently not actually used; places in code that have to be adapted are marked with `TODO(preserve_time)`.
At this point in time, all the new tests are failing right now; as they should, because the functionality of `preserve_time` has not been implemented yet.
All logic for the added `preserve_time` parameter is contained in that function, so other pieces of code just have to make a single call. It's still not implemented at this point.
…changing the access time itself was an access.
@atollk
Copy link
Member Author

atollk commented Mar 20, 2021

I wanted to add https://github.com/wolever/parameterized as a dependency because parameterization was done already anyway, just in a hacky self-implemented way. I don't actually get how to add test dependencies though?

@althonos
Copy link
Member

If you want to add a dependency for the tests, add it to tests/requirements.txt, pinning the version with ~= if possible. It will get installed by tox and by the CI runner.

atollk and others added 5 commits March 27, 2021 17:37
…me guarantees.

As it turns out, there are platforms which do not allow changing either atime or ctime to custom values. Thus, the proposed behavior was impossible to implement. `preserve_time` now only makes guarantees about mtime.
@coveralls
Copy link

coveralls commented Apr 1, 2021

Coverage Status

Coverage decreased (-0.01%) to 95.266% when pulling ebcd1a9 on atollk:issue_450 into 5f73778 on PyFilesystem:master.

@atollk
Copy link
Member Author

atollk commented Apr 1, 2021

@althonos From what I can tell, this doesn't work here, as the tests are run without tox.

@althonos
Copy link
Member

althonos commented Apr 1, 2021

@atollk : that was not expected, I patched appveyor.yml. I need to refactor the CI on AppVeyor anyway, since we are currently not testing all supported versions or measuring coverage there.

@atollk atollk marked this pull request as ready for review April 1, 2021 11:46
@atollk
Copy link
Member Author

atollk commented Apr 7, 2021

I just saw that FTPFS.setinfo actually doesn't do anything, so I also added support for the MFMT command so that preserve_time works when copying to a FTPFS too.

…ng used, rather than being assumed to be True always.
Copy link
Member

@althonos althonos left a comment

Choose a reason for hiding this comment

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

I'm not 100% satisfied with the copy_mtime name, because we never refer to mtime anywhere else in the API (we use modified everywhere). Yet copy_modified does not convey the function usecase very well. copy_modified_time maybe? Might be a bit too long.

There are just a few minore issues here and there but overall this looks fine.

atollk added 5 commits April 8, 2021 11:44
# Conflicts:
#	fs/copy.py
#	tests/test_copy.py
In a certain special case, the parameter was not passed on correctly but always `False` instead.
Before, `setinfo` would always start by sending a MLST or LIST command to find whether the resources exists. This is actually not necessary if MFMT is sent anyway, so the command is now skipped in that case.
@atollk atollk requested a review from althonos April 9, 2021 15:35
Copy link
Member

@althonos althonos left a comment

Choose a reason for hiding this comment

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

LGTM, congrats!

@althonos althonos merged commit ac8a91a into PyFilesystem:master Apr 12, 2021
@althonos
Copy link
Member

I merged this one because I have already been too nit-picky here, but for the remaining PRs, would you be able to rebase them to master so that the commit history is still a bit organized?

@atollk
Copy link
Member Author

atollk commented Apr 12, 2021

@althonos Sure can do. But I'd also be happy to write a more thorough commit message for a squash merge, since I feel a good part of the commits in those PRs are just one-file fixes anyway. Or do you not do squashes in this repo?

@althonos
Copy link
Member

The developer interaction was minimal here for some time so we just went with merges. I do squashes in other projects but for PyFilesystem I didn't wanna change what was there so branch/merges are fine. As long as they are properly rebased, the network is still fine: https://github.com/PyFilesystem/pyfilesystem2/network

@atollk
Copy link
Member Author

atollk commented Apr 21, 2021

@althonos In case you didn't see, I did a rebase in both #462 and #464.

@althonos
Copy link
Member

Thanks, perfect, i'll have a look tomorrow !

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.

original timestamp (ctime, mtime) cannot survive a copy_fs or mirror
3 participants