the changes are small and easy, but because I wrapped code into an if, it looks like a big change.
the cache is managed in listFiles() only.
it is a Map indexed by the uri.
it is invalidated by setting a dirty flag.
if dirty was set before, the cache is completely removed
on an empty cache the old body of listFiles is evaluated and the result is stored in the cache
The cache is invalidated at the beginning of getApplicationList().
Any change of the backup folder is usually followed by refreah which invokes getApplicationList.
If StorageFile should ever be used for more general purposes, getApplicationList would not be sufficient.
The more correct way would then be to handle all storage operations by the same class (or a collaborating system of classes) to have full control over all changes on the underlying file system initiated by the app.
Even more correct (changes from outside) would be to use file watchers.
the changes are small and easy, but because I wrapped code into an if, it looks like a big change.
The cache is invalidated at the beginning of getApplicationList(). Any change of the backup folder is usually followed by refreah which invokes getApplicationList.
If StorageFile should ever be used for more general purposes, getApplicationList would not be sufficient. The more correct way would then be to handle all storage operations by the same class (or a collaborating system of classes) to have full control over all changes on the underlying file system initiated by the app. Even more correct (changes from outside) would be to use file watchers.