v1.0.15: ON_CHANGE file watching, browser fix, rich notifications
- Add FileWatchService for real-time ON_CHANGE sync (FileObserver for direct paths, ContentObserver for SAF content:// URIs), 5s debounce - Fix remote browser stuck spinner: cancel in-flight jobs on navigation, reset entries immediately, add Retry button on error - Fix browser reuse bug: LaunchedEffect key now includes initialPath - Fix WebDavProvider: rethrow XML parse errors (no more silent Empty folder) and URL-decode file names from href - Notifications now use BigTextStyle showing per-file-type counts (Uploaded/Downloaded/Deleted) matching Autosync notification style - Wire FileWatchService into BootReceiver and HomeViewModel toggle - Register FileWatchService in AndroidManifest Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -158,43 +158,42 @@ open class WebDavProvider(protected val account: CloudAccount) : CloudProvider {
|
||||
|
||||
private fun parsePropfind(xml: String, parentPath: String, dropFirst: Boolean = true): List<RemoteFile> {
|
||||
val results = mutableListOf<RemoteFile>()
|
||||
try {
|
||||
val factory = XmlPullParserFactory.newInstance()
|
||||
factory.isNamespaceAware = true
|
||||
val parser = factory.newPullParser()
|
||||
parser.setInput(xml.reader())
|
||||
val factory = XmlPullParserFactory.newInstance()
|
||||
factory.isNamespaceAware = true
|
||||
val parser = factory.newPullParser()
|
||||
parser.setInput(xml.reader())
|
||||
|
||||
var href = ""; var isCollection = false; var contentLength = 0L
|
||||
var lastModified: Instant = Instant.EPOCH; var etag: String? = null; var contentType: String? = null
|
||||
var inResponse = false; var inProp = false
|
||||
var href = ""; var isCollection = false; var contentLength = 0L
|
||||
var lastModified: Instant = Instant.EPOCH; var etag: String? = null; var contentType: String? = null
|
||||
var inResponse = false; var inProp = false
|
||||
|
||||
var eventType = parser.eventType
|
||||
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||
val tag = parser.name?.substringAfterLast(':')?.lowercase()
|
||||
when (eventType) {
|
||||
XmlPullParser.START_TAG -> when (tag) {
|
||||
"response" -> { inResponse = true; href = ""; isCollection = false; contentLength = 0L; lastModified = Instant.EPOCH; etag = null; contentType = null }
|
||||
"prop" -> inProp = true
|
||||
"href" -> if (!inProp) href = parser.nextText().trim()
|
||||
"collection" -> if (inProp) isCollection = true
|
||||
"getcontentlength" -> if (inProp) contentLength = parser.nextText().trim().toLongOrNull() ?: 0L
|
||||
"getlastmodified" -> if (inProp) lastModified = parseHttpDate(parser.nextText().trim())
|
||||
"getetag" -> if (inProp) etag = parser.nextText().trim().trim('"')
|
||||
"getcontenttype" -> if (inProp) contentType = parser.nextText().trim()
|
||||
}
|
||||
XmlPullParser.END_TAG -> when (tag) {
|
||||
"prop" -> inProp = false
|
||||
"response" -> if (inResponse && href.isNotBlank()) {
|
||||
val name = href.trimEnd('/').substringAfterLast('/')
|
||||
val relPath = "$parentPath/$name".replace("//", "/")
|
||||
results.add(RemoteFile(relPath, name, isCollection, contentLength, lastModified, etag, contentType))
|
||||
inResponse = false
|
||||
}
|
||||
var eventType = parser.eventType
|
||||
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||
val tag = parser.name?.substringAfterLast(':')?.lowercase()
|
||||
when (eventType) {
|
||||
XmlPullParser.START_TAG -> when (tag) {
|
||||
"response" -> { inResponse = true; href = ""; isCollection = false; contentLength = 0L; lastModified = Instant.EPOCH; etag = null; contentType = null }
|
||||
"prop" -> inProp = true
|
||||
"href" -> if (!inProp) href = parser.nextText().trim()
|
||||
"collection" -> if (inProp) isCollection = true
|
||||
"getcontentlength" -> if (inProp) contentLength = parser.nextText().trim().toLongOrNull() ?: 0L
|
||||
"getlastmodified" -> if (inProp) lastModified = parseHttpDate(parser.nextText().trim())
|
||||
"getetag" -> if (inProp) etag = parser.nextText().trim().trim('"')
|
||||
"getcontenttype" -> if (inProp) contentType = parser.nextText().trim()
|
||||
}
|
||||
XmlPullParser.END_TAG -> when (tag) {
|
||||
"prop" -> inProp = false
|
||||
"response" -> if (inResponse && href.isNotBlank()) {
|
||||
val rawName = href.trimEnd('/').substringAfterLast('/')
|
||||
val name = try { java.net.URLDecoder.decode(rawName, "UTF-8") } catch (_: Exception) { rawName }
|
||||
val relPath = "$parentPath/$name".replace("//", "/")
|
||||
results.add(RemoteFile(relPath, name, isCollection, contentLength, lastModified, etag, contentType))
|
||||
inResponse = false
|
||||
}
|
||||
}
|
||||
eventType = parser.next()
|
||||
}
|
||||
} catch (_: Exception) {}
|
||||
eventType = parser.next()
|
||||
}
|
||||
return if (dropFirst) results.drop(1) else results
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user