Remove a file from the folder. Verify the index has entry with its path.
Load index.
Last step fails, the index is completely rebuilt in this case.
Pay attention to WARN lines:
[kirill@lenovo TEST]$ RUST_LOG=info ark-cli monitor
Building index of folder /tmp/TEST
[2023-03-06T16:21:33Z INFO arklib] Index has not been registered before
[2023-03-06T16:21:33Z INFO arklib::index] Loading the index from file
[2023-03-06T16:21:33Z WARN arklib::index] No persisted index was found by path /tmp/TEST/.ark/index
[2023-03-06T16:21:33Z INFO arklib::index] Building the index from scratch
[2023-03-06T16:21:36Z INFO arklib::index] Index built
[2023-03-06T16:21:36Z INFO arklib::index] Storing the index to file
[2023-03-06T16:21:36Z INFO arklib] Index was registered
Build succeeded in 3.667931346s
Updating succeeded in 158.747289ms
^C
[kirill@lenovo TEST]$ RUST_LOG=info ark-cli monitor #just load index from the file and check for updates
Building index of folder /tmp/TEST
[2023-03-06T16:21:57Z INFO arklib] Index has not been registered before
[2023-03-06T16:21:57Z INFO arklib::index] Loading the index from file
[2023-03-06T16:21:58Z INFO arklib::index] Storing the index to file
[2023-03-06T16:21:58Z INFO arklib] Index was registered
Build succeeded in 297.370813ms
^C
[kirill@lenovo TEST]$ grep gagarin .ark/index
1678115269692 200433-880886451 gagarin.jpg
[kirill@lenovo TEST]$ mv gagarin.jpg /tmp/
[kirill@lenovo TEST]$ RUST_LOG=info ark-cli monitor #must load the index and remove disappeared resource
Building index of folder /tmp/TEST
[2023-03-06T16:22:43Z INFO arklib] Index has not been registered before
[2023-03-06T16:22:43Z INFO arklib::index] Loading the index from file
[2023-03-06T16:22:43Z WARN arklib::index] No such file or directory (os error 2)
[2023-03-06T16:22:43Z INFO arklib::index] Building the index from scratch
[2023-03-06T16:22:47Z INFO arklib::index] Index built
[2023-03-06T16:22:47Z INFO arklib::index] Storing the index to file
[2023-03-06T16:22:47Z INFO arklib] Index was registered
Build succeeded in 3.651734571s
ark-cli monitor
..ark/index
exists.Pay attention to
WARN
lines:Thanks @mdrlzy for discovering this bug.