sbergwall / RobocopyPS

RobocopyPS
MIT License
51 stars 9 forks source link

Parser fails to interpret hours more than 24:00:00 on long runs #12

Closed fjollberg closed 2 years ago

fjollberg commented 2 years ago

This seem to fail for really long running jobs (days). Not 100% certain this is the crash I see, but believe it is.

MetadataError: Cannot convert value "68:49:05" to type "System.TimeSpan". Error: "The TimeSpan string '68:49:05' could not be parsed because at least one of the numeric components is out of range or contains too many digits.

https://github.com/sbergwall/RobocopyPS/blob/ca1653d37b632f0a52614e8cff79a99e18676e47/RobocopyPS/internal/Invoke-RobocopyParser.ps1#L103

Eg: > [TImespan]$d = "68:49:05" MetadataError: Cannot convert value "68:49:05" to type "System.TimeSpan". Error: "The TimeSpan string '68:49:05' could not be parsed because at least one of the numeric components is out of range or contains too many digits."

I guess it's hours:minutes:seconds, but the Timespan parser want to interpret it some other way by default.

See e.g.: https://stackoverflow.com/questions/2728321/how-to-parse-string-with-hours-greater-than-24-to-timespan

fjollberg commented 2 years ago

It's a little bit more complicated than 24 hours. If the timestamp is higher than 23:59:59 the first digit is interpreted as number of days, which still won't crasch for valid such numbers (even if the result is still wrong in this context).

sbergwall commented 2 years ago

This should be fixed in the dev branch with version 0.2.13.

fjollberg commented 2 years ago

Yes, this works fine in the new version.