Closed ktiedt closed 1 year ago
Some notes to self for the updated implementation of this feature (to be finished in the next couple days). TL;DR: I should be able to make this feature work fully for Windows and partially on Linux. macOS seems to be somewhere in between.
The proposed implementation uses the filedate
package for python to set the access, modification, and creation dates of an existing file. However, (1) this package is a simple wrapper around basic python that could be implemented directly, and (2) this package is not entirely honest about its own limitations which should be documented clearly. I intend to implement something directly into xbox2local
to get this feature without adding a dependency.
As best summarized here, there is no consistent, cross-platform way of accessing and/or modifying all three types of file dates.
A file's access time can be accessed using os.stat().st_atime
and its modification time can be accessed using either os.stat().st_mtime
or os.path.getmtime()
. The access and modification times can be modified simultaneously using os.utime()
as described here with examples.
File creation times have different rule sets across Windows, macOS, and Linux.
os.stat().st_ctime
or os.path.getctime()
. The creation time can be modified using several strategies that are Windows-specific, such as this and this. These are the approaches taken by the filedate
package.os.stat().st_birthtime
. I wasn't able to find any documentation on how to modify the creation time, but based on the screenshot above it seems that filedate
's approach was okay? However, I have my reservations based on....st_ctime
variable refers not to the creation time, but to the last time that the file's contents or metadata were changed. The Linux kernel does not keep any file creation data, so calls to os.stat()
on Linux don't help us. Updating it is similarly impossible for Linux, barring a custom C extension.I was testing on macOS so it was definitely working there. Great notes though. Thanks again!
Addressed by #24, and will be included in an upcoming v2.1.
I was able to get this functionality with just a couple lines of code (without adding the filedate
dependency). I also added a new function you can run in update.py
to apply capture datetimes to all previously downloaded media without having to delete/redownload them.
This was a very rough work around, in my opinion, but it does work. You can see the results of this in the attached screenshot. These files were downloaded yesterday after patching my local copy with this change.