Closed johot closed 9 months ago
Is there any current workaround to this
Not supported by this API, no :/ There is no way to explicitly set file metadata. Most discussions about extending support for file metadata have been read-only for now (see https://github.com/whatwg/fs/issues/12)
I would recommend exploring workarounds you can do at the application level
plans to add a
fileHandle.copy(...)
method or similair
Not currently, though if a copy()
method were to be added, my intuition is that most developers would expect the copied file would have a different creation time and last-modified time. For example:
touch original.txt
cp original.txt copy.txt
stat original.txt # this will be different
stat copy.txt # than this
Thank you for your answer @a-sully .
You are correct that the above commands will actually change the last modified time. However on Windows for example this is not the default case. If using Linux etc and providing the cp -p
(preserve) option the last modified date will also be preserved when copying a file.
I do understand that for many it doesn't matter if the last modified date gets changed but for my specific usecase its a dealbreaker (copying photos where the last modified time is the date the photo was taken and it has no EXIF metadata). The only workaround I could come up with would involve adding files to a zip file to preserve dates.
But I would also argue that having a copy method would make sense for other purposes the most important one being simplicity (and perhaps performance?).
My current plan is unfortunately to move over to Electron for my app which is a bit of a bummer but I do understand you guys have to prioritize. If this discussion ever comes up again feel free to think of this usecase :D
Thank you!
Anyone know if this is possible or planned to be implemented in the future?
I am building a photo sorter application of sorts and everything has been going great except for one thing that is currently a major blocker for me.
When copying files I have to basically create a new file using
.getFileHandle(name, { create: true })
and then write to that file usingcreateWritable(...)
. This works and creates a copy of any file but the last modified date gets set to the current date which potentially destroys a crucial part of file metadata in the case of a photo.Is there any current workaround to this or plans to add a
fileHandle.copy(...)
method or similair? I did see amove
method actually exists that works almost like I want but I don't want to affect any original files.Thank you for all your hard work with this API it brings so many new possibilities đź‘Ť