Repository navigation
Fix FileStatisticsDataEx reading the access time as the modified time - #141
Merged
Merged
Conversation
ModifiedTime and ChangedTime were placed one 8-byte field early, so ModifiedTime overlapped AccessTime (offset 44) and ChangedTime read the modified time (52). Per adbd's sync_stat_v2 layout they sit at 52 and 60. The listing tests used one timestamp for all three times, which hid the overlap; the first entry now has distinct times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Here again as with the previous PR - Claude found a bug with the parsing of LIS2 vs ADB source code, confirmed by comparing it against |
InstallMultiplePackageAsync counted finished splits with ++count inside callback?.Invoke(...) in parallel continuations, which had three effects: - Without a callback, the argument (and ++count) was never evaluated, so every multi-package install threw "2 should process but only 0 processed". - Two continuations could increment at once and lose one, throwing "only 1 processed" (the intermittent InstallMultiplePackageAsyncTest failure). - Reports could arrive out of order, PackageFinished going 2 then 1. The count now increments on its own, and with the callback under a lock. InstallMultiplePackageWithoutCallbackAsyncTest covers the first case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the timestamp-decoding and asynchronous split-install completion-counting changes.
No open issues 🎉
What changed in this PR
Corrects timestamp decoding for StatEx and extended directory listings, and fixes completion counting during asynchronous split-package installation.
Changes:
- Moves
ModifiedTimeandChangedTimeto their correct protocol offsets. - Synchronizes split completion counts and progress callbacks, while counting completions even without a callback.
- Adds regression coverage for distinct timestamps and callback-free installs.
| File | Description |
|---|---|
AdvancedSharpAdbClient/Models/FileStatisticsData.V2.cs |
Corrects modification and change timestamp offsets. |
AdvancedSharpAdbClient/DeviceCommands/PackageManager.Async.cs |
Protects completion counts and orders progress reports in four parallel blocks. |
AdvancedSharpAdbClient.Tests/SyncServiceTests.cs |
Uses distinct timestamps to detect incorrect field offsets. |
AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs |
Adds distinct timestamp checks to both asynchronous listing variants. |
AdvancedSharpAdbClient.Tests/DeviceCommands/PackageManagerTests.Async.cs |
Tests both split-package install overloads without callbacks. |
Review effort: Balanced
Fix warning
Member
|
Thanks for your AI. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
FileStatisticsDataEx(used byStatExandGetDirectoryListingEx) placesModifiedTimeandChangedTimeone 8-byte field too early:AccessTimeModifiedTimeChangedTimeSo
ModifiedTimereturns the access time,ChangedTimereturns the modified time, and the real ctime is never read.IFileStatistics.TimeandToString()both useModifiedTime, so every V2 listing shows access times as modification times.Source
adbd's packed
sync_stat_v2/sync_dent_v2infile_sync_protocol.h(lines 55-68 and 78-92) declare, after theidthatReadSyncResponseconsumes:error(u32) ·dev(u64) ·ino(u64) ·mode(u32) ·nlink(u32) ·uid(u32) ·gid(u32) ·size(u64) ·atime(i64) ·mtime(i64) ·ctime(i64)That puts
atimeat 5×4 + 3×8 = 44,mtimeat 52 andctimeat 60, for the 68-byteLengththe struct already declares. This file is the one linked in the struct's own<remarks>.Changes
FileStatisticsData.V2.cs:ModifiedTimeat(5 * sizeof(uint)) + (3 * sizeof(ulong)) + sizeof(long),ChangedTimeat... + (2 * sizeof(long)).GetListingExTest,GetListingExAsyncTestandGetAsyncListingExTestnow has atime/mtime/ctime one second apart. Those three tests fail without the fix and pass with it; all 28SyncServiceTestspass.Also: split install counts in
InstallMultiplePackageAsyncThe first CI run failed
PackageManagerTests.InstallMultiplePackageAsyncTeston Windows. That's unrelated to the stat change: on an unmodifiedmainbuild it fails about 2 runs in 10. The cause is inPackageManager.Async.cs, where the parallel continuations count finished splits withcallback?.Invoke(new InstallProgressEventArgs(++count, ...)):?.skips evaluating the argument, so++countnever runs and every multi-package install without a callback throws... 2 should process but only 0 processed.ConfigureAwait(false), so on pool threads) can increment at once and lose one, throwing... only 1 processed.This is the CI failure.PackageFinishedgoing 2 then 1, which the test's progress checker rejects.The count now increments on its own line, under a lock together with the callback, in all four parallel blocks (remove after install, both overloads; write session, both overloads). The synchronous versions are sequential and don't check the count, so they're unchanged.
New test
InstallMultiplePackageWithoutCallbackAsyncTestfails onmainand passes with the fix.PackageManagerTestspassed 50 of 50 runs locally, and the full suite passes (689 tests).🤖 Generated with Claude Code