ARK-Builders / arklib

Core of the programs in ARK family
MIT License
1 stars 10 forks source link

Missing file causes index loading failure and leads to complete rebuild #34

Closed kirillt closed 6 months ago

kirillt commented 1 year ago
  1. Build index of some folder using ark-cli monitor.
  2. Verify .ark/index exists.
  3. Remove a file from the folder. Verify the index has entry with its path.
  4. 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

Thanks @mdrlzy for discovering this bug.

kirillt commented 8 months ago

Must be fixed, verify using ark-cli

kirillt commented 6 months ago

We need to finish this PR first:

kirillt commented 6 months ago

This is fixed. On my test folder, fresh index build spends 16 sec. If some files are deleted, the index update spends 2 sec.