pyfilesystem2 icon indicating copy to clipboard operation
pyfilesystem2 copied to clipboard

#556 Fallback to alternate mtime correctly

Open james-emerton opened this issue 3 years ago • 2 comments

Type of changes

  • Bug fix

Checklist

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

Description

This addresses an issues where write_zip() assumed that the details namespace was always available. The stat namespace will be checked first, followed by details, and finally the current time will be used if st_mtime is still None.

I'm willing to author a test against this, but I'm only aware of this being an issue with the s3 filesystem (and only when it encounters a directory) and I'm not certain how best to test that here.

https://github.com/PyFilesystem/pyfilesystem2/issues/556

james-emerton avatar Oct 27 '22 00:10 james-emerton

Hi James, sorry for the delay in answering, my real-life job has been taking a lot of my time away :sweat:

A test would be very appreciated, as to avoid any regression (in case the code is changed or refactored, it would be better not to have this issue pop up again later). For this you can probably subclass MemoryFS and make a derived version of getinfo that never returns the details namespace.

althonos avatar Dec 02 '22 09:12 althonos

@althonos I've added a test for the fallback mtime behaviour, and I think this should now be ready for another look.

james-emerton avatar Dec 05 '22 20:12 james-emerton