Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions app/src/main/java/com/nextcloud/client/database/dao/FileDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,19 @@ interface FileDao {

@Query(
"""
SELECT
EXISTS (
SELECT 1
FROM filelist
WHERE parent = :parentId
AND file_owner = :accountName
AND content_type != '${MimeType.DIRECTORY}'
AND content_type != '${MimeType.WEBDAV_FOLDER}'
)
AND NOT EXISTS (
SELECT 1
FROM filelist
WHERE parent = :parentId
AND file_owner = :accountName
AND content_type != '${MimeType.DIRECTORY}'
AND content_type != '${MimeType.WEBDAV_FOLDER}'
AND media_path IS NULL
)
SELECT NOT EXISTS (
SELECT 1
FROM filelist
WHERE parent = :parentId
AND file_owner = :accountName
AND content_type IS NOT NULL
AND content_type != '${MimeType.DIRECTORY}'
AND content_type != '${MimeType.WEBDAV_FOLDER}'
AND (media_path IS NULL OR TRIM(media_path) = '')
)
"""
)
fun isFolderFullyDownloaded(parentId: Long, accountName: String): Boolean
fun areAllFilesHaveMediaPath(parentId: Long, accountName: String): Boolean

@Query(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fun Path.toLocalPath(): String = toAbsolutePath().toString()
@Suppress("ReturnCount")
fun String.toFile(): File? {
if (isNullOrEmpty()) {
Log_OC.e(TAG, "given path is null or empty")
Log_OC.w(TAG, "given path is null or empty: $this")
return null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,19 @@ class OCFileListDelegate(
}

private fun showLocalFileIndicator(file: OCFile, holder: ListViewHolder) {
val isFullyDownloaded = storageManager.fileDao.isFolderFullyDownloaded(file.fileId, user.accountName)
var isFolderDown = false
if (file.isFolder && !file.isEncrypted && file.fileLength != 0L) {
isFolderDown = storageManager.fileDao.areAllFilesHaveMediaPath(file.fileId, user.accountName)
}

val isSyncing = isSynchronizing(file)
val hasConflict = (file.etagInConflict != null)
val isDown = file.isDown

val icon = when {
isSyncing -> R.drawable.ic_synchronizing
hasConflict -> R.drawable.ic_synchronizing_error
isDown || isFullyDownloaded -> R.drawable.ic_synced
isDown || isFolderDown -> R.drawable.ic_synced
else -> null
}

Expand Down
Loading