Closed tareknaser closed 4 months ago
@tareknaser could you also check this issue?
About change from milliseconds to nanoseconds in timestamps: we should double-check that we really can have nanoseconds on mobile platforms. I don't remember precisely, but it seems we had an issue with nanoseconds due to implicit rounding to milliseconds. Could be so even on Linux.
We should investigate why this threshold was introduced: https://github.com/ARK-Builders/arklib/commit/267b844f3a0f04586c7d6178180607fc3cb0fa0d#diff-701633ed548410624cfcae90d38a986adbd60deb5aeedd92355fe2e7702a9c18L34
About change from milliseconds to nanoseconds in timestamps: we should double-check that we really can have nanoseconds on mobile platforms. I don't remember precisely, but it seems we had an issue with nanoseconds due to implicit rounding to milliseconds. Could be so even on Linux.
Before making any changes to arklib
on how time is stored, we need to understand the impact of storing time in nanosecond on mobile systems.
If we must keep the millisecond precision, we have two options to consider:
IndexEntry
objects won't be equal when writing to ark file and then reading from it.last_modified
of each entry. This can be done by converting the SystemTime
to milliseconds in scan_entry
as follows:
let duration = modified
.duration_since(UNIX_EPOCH)
.expect("SystemTime before UNIX EPOCH!")
.as_millis();
let modified =
UNIX_EPOCH + std::time::Duration::from_millis(duration as u64);
@tareknaser we could use nanoseconds, but:
I could imagine us needing microseconds to timestamp realistically filesystem events. Would we have the rounding issues in this case?
We can track only milliseconds when retrieving
last_modified
of each entry. This can be done by converting theSystemTime
to milliseconds inscan_entry
This sounds like the way to go.
We can keep the current implementation, which stores time in milliseconds. Only problem is that IndexEntry objects won't be equal when writing to ark file and then reading from it.
Is this sill a problem if we go the way with converting to milliseconds in scan_entry
?
Do we really need such a precision? Can several filesystem writes happen with time difference of e.g. 10ns? I hope milliseconds is enough.
Yes I think milliseconds is enough. Only issue is https://github.com/ARK-Builders/arklib/pull/87#discussion_r1509775947
Is this sill a problem if we go the way with converting to milliseconds in scan_entry?
No. that should solve it
Description
This PR focuses on refactoring the
src/index.rs
file.Changes
The changes primarily include:
serde::{Deserialize, Serialize}
for loading and storing of the index filediscover_paths
function todiscover_files
TempDir
for testing#[cfg(target_family = "unix")]
)Edit
Fixes #89 with 633335ab42a603fe646b1bfe7b687a271b7ab9b3