mirror of
https://github.com/immich-app/immich.git
synced 2025-12-21 17:25:35 +03:00
fix: handle null bucketId or name in android local sync (#23224)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
@@ -101,9 +101,15 @@ open class NativeSyncApiImplBase(context: Context) : ImmichPlugin() {
|
|||||||
|
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
val id = c.getLong(idColumn).toString()
|
val id = c.getLong(idColumn).toString()
|
||||||
|
val name = c.getStringOrNull(nameColumn)
|
||||||
|
val bucketId = c.getStringOrNull(bucketIdColumn)
|
||||||
|
val path = c.getStringOrNull(dataColumn)
|
||||||
|
|
||||||
val path = c.getString(dataColumn)
|
// Skip assets with invalid metadata
|
||||||
if (path.isNullOrBlank() || !File(path).exists()) {
|
if (
|
||||||
|
name.isNullOrBlank() || bucketId.isNullOrBlank() ||
|
||||||
|
path.isNullOrBlank() || !File(path).exists()
|
||||||
|
) {
|
||||||
yield(AssetResult.InvalidAsset(id))
|
yield(AssetResult.InvalidAsset(id))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -113,7 +119,6 @@ open class NativeSyncApiImplBase(context: Context) : ImmichPlugin() {
|
|||||||
MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO -> 2
|
MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO -> 2
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
val name = c.getString(nameColumn)
|
|
||||||
// Date taken is milliseconds since epoch, Date added is seconds since epoch
|
// Date taken is milliseconds since epoch, Date added is seconds since epoch
|
||||||
val createdAt = (c.getLong(dateTakenColumn).takeIf { it > 0 }?.div(1000))
|
val createdAt = (c.getLong(dateTakenColumn).takeIf { it > 0 }?.div(1000))
|
||||||
?: c.getLong(dateAddedColumn)
|
?: c.getLong(dateAddedColumn)
|
||||||
@@ -124,7 +129,6 @@ open class NativeSyncApiImplBase(context: Context) : ImmichPlugin() {
|
|||||||
// Duration is milliseconds
|
// Duration is milliseconds
|
||||||
val duration = if (mediaType == MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE) 0
|
val duration = if (mediaType == MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE) 0
|
||||||
else c.getLong(durationColumn) / 1000
|
else c.getLong(durationColumn) / 1000
|
||||||
val bucketId = c.getString(bucketIdColumn)
|
|
||||||
val orientation = c.getInt(orientationColumn)
|
val orientation = c.getInt(orientationColumn)
|
||||||
val isFavorite = if (favoriteColumn == -1) false else c.getInt(favoriteColumn) != 0
|
val isFavorite = if (favoriteColumn == -1) false else c.getInt(favoriteColumn) != 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user