mirror of https://github.com/koreader/koreader
[Android] Migrate user directories after update (#6287)
I've played a bit with #6275, to make the iterator available for non-power users too. this PR automate user data migration (which happens once per update). If the folder `koreader/scripts.afterupdate` contains a file `migrate` then files will be copied to internal dir preserving their relative path. Thus user data **needs** to have the same hierarchy as internal directories. Shell scripts will be find and run if the folder `koreader/scripts.afterupdate` exists and has no `migrate file`. In the case of `koreader/scripts.always` there's no migration available, just shell scripts. Digging a bit seems not possible to create new directories on app internal storage (it just crashes on the emulator since API25). So very fancy extensions are not supported, but it is ok to override files and create new files if dir already exists. Tested with: ```find scripts.afterupdate/ scripts.afterupdate/ scripts.afterupdate/data scripts.afterupdate/data/hyph scripts.afterupdate/data/hyph/Roman.pattern scripts.afterupdate/data/example.css scripts.afterupdate/migrate ``` Results: ``` 06-20 16:16:33.590 3584 3597 I KOReader: after-update: running migration 06-20 16:16:33.596 3584 3597 I KOReader: command cp /storage/emulated/0/koreader/scripts.afterupdate/data/hyph/Roman.pattern /data/user/0/org.koreader.launcher/files/data/hyph/Roman.pattern returned 0 06-20 16:16:33.600 3584 3597 I KOReader: command cp /storage/emulated/0/koreader/scripts.afterupdate/data/example.css /data/user/0/org.koreader.launcher/files/data/example.css returned 0 06-20 16:16:33.604 3584 3597 I KOReader: command rm /data/user/0/org.koreader.launcher/files/afterupdate.marker returned 0 ```reviewable/pr6288/r1
parent
416c1c7356
commit
699ee3efc1
Loading…
Reference in New Issue