Fix verification messaging: distinguish three copy outcomes
Three states: 1. SHA-256 verified (green) — remote hash matched dest hash 2. Copied, no remote checksum (secondary color) — file copied OK, device doesn't support sha256sum (Samsung/toybox) 3. Failed (red) — copy exception or hash mismatch Previously all non-checksum cases showed 'may be corrupt' which was a false alarm on devices without sha256sum support.
This commit is contained in:
@@ -143,7 +143,11 @@ class Copier(
|
|||||||
destSha256 = destHash,
|
destSha256 = destHash,
|
||||||
verified = verified,
|
verified = verified,
|
||||||
convertedFromHeic = wasConverted,
|
convertedFromHeic = wasConverted,
|
||||||
error = if (!verified) "Hash mismatch — file may be corrupt" else null,
|
error = when {
|
||||||
|
!verified && remoteHash != null -> "Hash mismatch — file may be corrupt"
|
||||||
|
!verified -> "Copy failed — file missing or empty"
|
||||||
|
else -> null
|
||||||
|
},
|
||||||
)
|
)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
pulledFile?.deleteIfExists()
|
pulledFile?.deleteIfExists()
|
||||||
|
|||||||
@@ -224,16 +224,27 @@ private fun ResultSummaryHeader(success: Int, failure: Int, destination: String)
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun CopyResultRow(result: CopyResult) {
|
private fun CopyResultRow(result: CopyResult) {
|
||||||
|
val hasRemoteHash = result.sourceSha256 != "(not available)"
|
||||||
|
val isVerifiedWithHash = result.verified && result.error == null && hasRemoteHash
|
||||||
|
val isVerifiedNoHash = result.verified && result.error == null && !hasRemoteHash
|
||||||
|
val isFailed = result.error != null || !result.verified
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp),
|
modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp),
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
if (result.verified && result.error == null) Icons.Default.CheckCircle else Icons.Default.Error,
|
when {
|
||||||
|
isFailed -> Icons.Default.Error
|
||||||
|
else -> Icons.Default.CheckCircle
|
||||||
|
},
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
tint = if (result.verified && result.error == null)
|
tint = when {
|
||||||
MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.error,
|
isFailed -> MaterialTheme.colorScheme.error
|
||||||
|
isVerifiedWithHash -> MaterialTheme.colorScheme.primary
|
||||||
|
else -> MaterialTheme.colorScheme.secondary // verified, no hash
|
||||||
|
},
|
||||||
modifier = Modifier.size(18.dp),
|
modifier = Modifier.size(18.dp),
|
||||||
)
|
)
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
@@ -241,16 +252,18 @@ private fun CopyResultRow(result: CopyResult) {
|
|||||||
"${result.photo.filename} → ${result.destinationPath.fileName}"
|
"${result.photo.filename} → ${result.destinationPath.fileName}"
|
||||||
else result.photo.filename
|
else result.photo.filename
|
||||||
Text(displayName, style = MaterialTheme.typography.bodySmall, fontWeight = FontWeight.Medium)
|
Text(displayName, style = MaterialTheme.typography.bodySmall, fontWeight = FontWeight.Medium)
|
||||||
if (result.error != null) {
|
Text(
|
||||||
Text(result.error, style = MaterialTheme.typography.labelSmall,
|
when {
|
||||||
color = MaterialTheme.colorScheme.error)
|
isFailed -> result.error ?: "Failed"
|
||||||
} else {
|
isVerifiedWithHash -> "SHA-256 verified · ${result.photo.sizeBytes / 1024} KB"
|
||||||
Text(
|
else -> "Copied · ${result.photo.sizeBytes / 1024} KB (no remote checksum)"
|
||||||
"${result.photo.sizeBytes / 1024} KB • SHA-256: ${result.destSha256.take(12)}…",
|
},
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = when {
|
||||||
)
|
isFailed -> MaterialTheme.colorScheme.error
|
||||||
}
|
else -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user