-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File Monitoring #107
File Monitoring #107
Conversation
678d4e5
to
9a005f8
Compare
@mdrlzy could you list issues which this PR solves? |
app/src/main/java/space/taran/arknavigator/mvp/model/RootAndFav.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/space/taran/arknavigator/mvp/model/RootAndFav.kt
Outdated
Show resolved
Hide resolved
9a005f8
to
88c4f51
Compare
|
||
class FSMonitoring( | ||
val indexCache: IndexCache, | ||
val tagsCache: TagsCache, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
class FSMonitoring( | ||
val indexCache: IndexCache, | ||
val tagsCache: TagsCache, | ||
val appScope: CoroutineScope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
} | ||
} | ||
|
||
private fun onDelete(root: Path, directory: Path, eventPath: Path) = appScope.launch(Dispatchers.Default) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directory
is not unused
tagsCache.remove(id) | ||
} | ||
|
||
private fun onMovedFrom(root: Path, directory: Path, eventPath: Path) = appScope.launch(Dispatchers.Default) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directory
is not unused
indexCache.onResourceDeleted(root, eventPath) | ||
} | ||
|
||
private fun onMovedTo(root: Path, directory: Path, eventPath: Path) = appScope.launch(Dispatchers.Default) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directory
is not unused
|
||
class RecursiveDirectoryObserver( | ||
private val fsMonitoring: FSMonitoring, | ||
private val root: String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not use strings to work with paths unless it's not impossible.
val root: Path
val parent: String = stack.pop() | ||
directoryObservers.add(DirectoryObserver.create(this, parent)) | ||
val path = File(parent) | ||
val files: Array<File> = path.listFiles() ?: continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use newer java.nio.file
package.
Files.list(path)
|
||
override fun onEvent(event: Int, path: String?) { | ||
val eventCode = event and ALL_EVENTS | ||
val eventPath = path?.let { "$directory/$path" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun log(directory: String, event: Int, eventPath: String?) { | ||
val eventName = provideEventName(event) | ||
eventName?.let { | ||
Timber.d("$eventName \n Directory: $directory \n Path: $eventPath") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use plain Log.d
with filesystem
tag?
@@ -22,6 +32,7 @@ class MainPresenter: MvpPresenter<MainView>() { | |||
|
|||
fun permsGranted() { | |||
Log.d(MAIN, "creating Folders screen") | |||
presenterScope.launch { indexingEngine.reindex() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reindexing all roots during start-up can take unnecessarily long time.
Renamed branch into |
No description provided.