FileMetadata with last modification information #463#488
FileMetadata with last modification information #463#488rcaceiro wants to merge 9 commits intoKotlin:masterfrom
Conversation
…adata` across platforms
|
We can support creationTime on linux by using statx and stx_btime. |
|
Yes, POSIX support that, however the stat structure that jetbrains expose doesn't have this information. |
| * Time when the file was last modified, or `null` if the filesystem does not support it. | ||
| */ | ||
| public val updatedAt: Instant? = null, | ||
| ) |
There was a problem hiding this comment.
Some FSs also provide information about the last access time, does it make sense to expose it too?
There was a problem hiding this comment.
@rcaceiro, It seems like the attribute is available in every other platform. So please add it to the metadata too.
There was a problem hiding this comment.
Yes I agree how ever in kotlin native the struct stat don't expose both create nor modified time
|
Yes I can expose it no problem, I focused in add something that is needed. |
|
Can you provide guidance about the best to do? |
|
@rcaceiro, |
# Conflicts: # core/nodeFilesystemShared/src/files/FileSystemNodeJs.kt
|
@fzhinkin Ok, its done |
|
Related: square/okio#1772 was merged recently, it adds creation time support for Linux and macOs. |
fzhinkin
left a comment
There was a problem hiding this comment.
@rcaceiro please make sure that all checks pass locally. You can refer https://github.com/Kotlin/kotlinx-io/blob/master/CONTRIBUTING.md#building for details.
| * Time when the file was last modified, or `null` if the filesystem does not support it. | ||
| */ | ||
| public val updatedAt: Instant? = null, | ||
| ) |
There was a problem hiding this comment.
@rcaceiro, It seems like the attribute is available in every other platform. So please add it to the metadata too.
Co-authored-by: Filipp Zhinkin <filipp.zhinkin@gmail.com>
Co-authored-by: Filipp Zhinkin <filipp.zhinkin@gmail.com>
Co-authored-by: Filipp Zhinkin <filipp.zhinkin@gmail.com>
…oss all filesystem implementations
| @OptIn(ExperimentalForeignApi::class) | ||
| public actual val SystemTemporaryDirectory: Path | ||
| get() = Path(getenv("TMPDIR")?.toKString() ?: getenv("TMP")?.toKString() ?: "") | ||
| get() = Path(getenv("TMPDIR")?.toKString() ?: getenv("TMP")?.toKString() ?: "/tmp") |
There was a problem hiding this comment.
It seems unrelated to extending file metadata.
| assertFalse(fileMetadata.isDirectory) | ||
| assertTrue(fileMetadata.isRegularFile) | ||
| assertTrue(validateAt(fileMetadata.createdAt, time)) | ||
| assertTrue(validateAt(fileMetadata.lastModificationTime, time)) |
There was a problem hiding this comment.
Please also check that if something will be written to the filepath after this check, then the modification time will be increased, but the creation time will remain the same (assuming both times are available).
And it's worth testing that at this point they are equal to each other (they should be, right?).
There was a problem hiding this comment.
I’ve completed the tests, but I’ve noted a discrepancy on JVM Linux: createdAt matches lastModifiedAt.
According to the documentation, if the file system doesn't support a specific creation timestamp, the JVM returns a default value—typically the last-modified time. Since this is expected behavior for certain Linux environments, I propose we skip this specific check on the JVM to allow the rest of the suite to pass.
How would you like me to proceed?
…cross all filesystem implementations
Add support for file creation and modification timestamps in
FileMetadataacross platformsThis pull request closes issue #463