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
Feature: Extended Time data #76
Conversation
Instead of having both Date and FileTime fields, I think I'm gonna keep only FileTime and make the getters and setters for the Date fields just interact get/set to the FileTime fields. WDYT? |
Hi, could you add a description of what the PR is about? It would be good to understand what this is without having to read the code. Thanks |
Codecov Report
@@ Coverage Diff @@
## master #76 +/- ##
=============================================
+ Coverage 31.74% 54.14% +22.39%
- Complexity 503 870 +367
=============================================
Files 90 90
Lines 4914 4972 +58
Branches 791 800 +9
=============================================
+ Hits 1560 2692 +1132
+ Misses 3153 1954 -1199
- Partials 201 326 +125
Continue to review full report at Codecov.
|
My bad. I thought I had written it clearly enough, but re-reading the description, I see it's a bit confusing. I'll be editing it. |
Done. Please check it out. |
|
||
{ | ||
//noinspection PointlessBitwiseExpression | ||
int flag = extTimeFlags >>> 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gotson This is here just we I can reuse the block below without changing anything. I figured out how to make it into a function and I'm gonna refactor it so it'll be a lot cleaner.
@@ -67,12 +73,20 @@ | |||
|
|||
private final byte[] salt = new byte[SALT_SIZE]; | |||
|
|||
private FileTime lastModifiedTime; | |||
|
|||
private Date mTime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gotson given the FileTime
fields above are available and contain the most accurate precision which reflects the extended time format better (and it also makes this more like ZipEntry
), I'm thinking it we can get rid of the java.util.Date
fields and just get them from the FileTime
equivalents when calling the getters (documenting the change accordingly, of course).
Ex.:
public Date getMTime() {
return toDate(lastModifiedTime);
}
I've never heard of the EXT_TIME header. Would you be able to share some context about what this is, how it can be used (outside this project), and what your proposed change can help do that couldn't be done before? |
@gotson I think I mistakenly called it EXT_TIME header but what I actually meant was EXT_TIME section of the header. I think WinRAR calls it "High precision time format". Time in RAR 4 and below is stored as an MS-DOS date/time 32-bit integer, which JUnrar decodes into a (local) The EXT_TIME flag in the header signals that the header contains additional data about file times. If the File Header contains this flag, it has a section which contains:
Each additional data section comprises:
Parsing this section of the file header enables it to parse dates correctly using all information available in the RAR file. For example, the following entry (output from the UnRAR CLI utility):
before this patch, is parsed as (notice the seconds which went from 55 to 54 because of the MS-DOS time/date format):
And after this patch, it's parsed correctly down to 100ns units. |
There was a |
And this is where I took most of the things here, including the pseudo-code: https://codedread.github.io/bitjs/docs/unrar.html See the ExtTime structure section. |
@gotson I just pushed some improvements, including now it being fully compatible with 100ns intervals. I think I ended up pushing some small optimization around array copies 😅 |
3fefe1c
to
a2fa427
Compare
I reverted most things, leaving only the functionality itself here. That way it's easier to review. |
I am just the maintainer of the project, the code is more than 15 years old :)
Thanks, i was going to ask for splitting up the various changes in multiple PRs, so it's easier to review and merge while keeping a nice commit history. Thanks a lot for the PR, i will review it when i have more time. |
a2fa427
to
6e6fd07
Compare
@gotson all PRs were updated. It seems you need to approve the workflows so they can run again against the latest changes. |
I think That would be a breaking change though, make sure you add |
I actually already did that. There's no breakage because the getters and setters are kept, but they get/set the FileTime fields in the appropriate ways. |
But you don't expose it externally though. Should it be? |
What do you mean? There are getter/setter methods for the FileTime fields that only get/set the objects themselves without any conversion. FileTimes are immutable, so that's safe to do. |
Ah! I didn't see you added new getter/setter and also kept the original. |
I'm wondering if the old getter/setter should be marked as deprecated. Thoughts? |
I thought about that, but they technically work for what they are for (e.g. save the user from doing some conversions) so I don't feel the need for that. It's up to you and how you'd prefer it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@theobisproject i would be happy to have your updated review before merging :) |
LGTM |
🎉 This PR is included in version 7.5.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Add parsing of extended time data
- Detects and parses the EXT_TIME part of the file header
-
java.util.Date
fields added or improved:-
atime
,ctime
andarctime
are now parsed, precision is milliseconds-
mtime
now has a maximum precision of milliseconds instead of seconds, when EXT_TIME is present- Corresponding
FileTime
fields added-
lastModifiedTime
,lastAccessTime
andcreationTime
fields added- precision for those is 100ns intervals