Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cpg314/mtime-rewind
Rewind the mtime of files whose mtime advanced since the last execution without a content change.
https://github.com/cpg314/mtime-rewind
cache cache-invalidation cargo mtime rust
Last synced: 1 day ago
JSON representation
Rewind the mtime of files whose mtime advanced since the last execution without a content change.
- Host: GitHub
- URL: https://github.com/cpg314/mtime-rewind
- Owner: cpg314
- License: apache-2.0
- Created: 2023-09-03T08:01:46.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-04T09:43:21.000Z (7 months ago)
- Last Synced: 2024-05-04T10:33:31.873Z (7 months ago)
- Topics: cache, cache-invalidation, cargo, mtime, rust
- Language: Rust
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# mtime-rewind
Rewind the `mtime` attribute of files whose modification advanced since the last execution without a content change.
This is useful to avoid unnecessary cache invalidations in systems using `mtime` to detect changes, for example [Rust's cargo](https://doc.rust-lang.org/cargo/) (see [this issue](https://github.com/rust-lang/cargo/issues/6529)).
More generally, see the [`mtime` comparison considered harmful blog post](https://apenwarr.ca/log/20181113).
## Usage
```console
$ mtime-rewind
Rewind the mtime of files whose mtime advanced since the last execution without a content changeUsage: mtime-rewind [OPTIONS]
Arguments:
Options:
--dry Do not edit only mtime, only list the changes that would be made
-h, --help Print help```
- The first execution will store hashes and modification times of files in a `.hashprint` file at the root. Hidden files and [cache directories](https://bford.info/cachedir/) are ignored.
- Subsequent executions will rewind files that have not changed to the previous modification time, and update the modification times of other files if necessary.Typically, `mtime-rewind` can be executed as the first step of a CI build.
## Example
```console
$ mtime-rewind ~/project
[INFO mtime_rewind] Computing hashes...
[INFO mtime_rewind] Computed hashes for 9 files
[INFO mtime_rewind] Writing hashes for the first time...
[INFO mtime_rewind] Wrote "/root/project/.hashprint"
[INFO mtime_rewind] Done
$ touch src/main.rs
[INFO mtime_rewind] Computing hashes...
[INFO mtime_rewind] Computed hashes for 9 files
[INFO mtime_rewind] Restoring modification times for unchanged files...
[INFO mtime_rewind] Loading cached state...
[INFO mtime_rewind] Loaded hashes for 9 files
[INFO mtime_rewind] Rewinding "/root/project/src/main.rs" from SystemTime { tv_sec: 1693727396, tv_nsec: 146042169 } to SystemTime { tv_sec: 1693727019, tv_nsec: 668108072 } as its contents did not change
[INFO mtime_rewind] 1 files rewinded
[INFO mtime_rewind] Saving the new state...
[INFO mtime_rewind] Wrote "/root/project/.hashprint"
[INFO mtime_rewind] Done
```