mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
fix(trash-sync): clean up NativeSyncApiImplBase and correct applyDelta
This commit is contained in:
parent
89d2d04ae4
commit
5582a08c3a
3 changed files with 11 additions and 11 deletions
|
|
@ -243,15 +243,13 @@ class BackgroundServicePlugin : FlutterPlugin, MethodChannel.MethodCallHandler,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val primary = ContentUris.withAppendedId(contentUriForType(type), id)
|
val uri = ContentUris.withAppendedId(contentUriForType(type), id)
|
||||||
val fallback = ContentUris.withAppendedId(MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL), id)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Log.i(TAG, "restoreFromTrashById: primary=$primary (type=$type,id=$id)")
|
Log.i(TAG, "restoreFromTrashById: uri=$uri (type=$type,id=$id)")
|
||||||
restoreUris(listOf(primary), result)
|
restoreUris(listOf(uri), result)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w(TAG, "restoreFromTrashById: primary failed, try fallback=$fallback", e)
|
Log.w(TAG, "restoreFromTrashById failed", e)
|
||||||
restoreUris(listOf(fallback), result)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,12 @@ sealed class AssetResult {
|
||||||
open class NativeSyncApiImplBase(context: Context) {
|
open class NativeSyncApiImplBase(context: Context) {
|
||||||
private val ctx: Context = context.applicationContext
|
private val ctx: Context = context.applicationContext
|
||||||
|
|
||||||
internal var hashTask: Job? = null
|
private var hashTask: Job? = null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val MAX_CONCURRENT_HASH_OPERATIONS = 16
|
private const val MAX_CONCURRENT_HASH_OPERATIONS = 16
|
||||||
internal val hashSemaphore = Semaphore(MAX_CONCURRENT_HASH_OPERATIONS)
|
private val hashSemaphore = Semaphore(MAX_CONCURRENT_HASH_OPERATIONS)
|
||||||
internal const val HASHING_CANCELLED_CODE = "HASH_CANCELLED"
|
private const val HASHING_CANCELLED_CODE = "HASH_CANCELLED"
|
||||||
|
|
||||||
const val MEDIA_SELECTION =
|
const val MEDIA_SELECTION =
|
||||||
"(${MediaStore.Files.FileColumns.MEDIA_TYPE} = ? OR ${MediaStore.Files.FileColumns.MEDIA_TYPE} = ?)"
|
"(${MediaStore.Files.FileColumns.MEDIA_TYPE} = ? OR ${MediaStore.Files.FileColumns.MEDIA_TYPE} = ?)"
|
||||||
|
|
@ -59,7 +59,7 @@ open class NativeSyncApiImplBase(context: Context) {
|
||||||
add(MediaStore.MediaColumns.HEIGHT)
|
add(MediaStore.MediaColumns.HEIGHT)
|
||||||
add(MediaStore.MediaColumns.DURATION)
|
add(MediaStore.MediaColumns.DURATION)
|
||||||
add(MediaStore.MediaColumns.ORIENTATION)
|
add(MediaStore.MediaColumns.ORIENTATION)
|
||||||
// only available on Android 11 and above
|
// IS_FAVORITE is only available on Android 11 and above
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
|
||||||
add(MediaStore.MediaColumns.IS_FAVORITE)
|
add(MediaStore.MediaColumns.IS_FAVORITE)
|
||||||
}
|
}
|
||||||
|
|
@ -138,6 +138,7 @@ open class NativeSyncApiImplBase(context: Context) {
|
||||||
val bucketId = c.getString(bucketIdColumn)
|
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
|
||||||
|
|
||||||
val asset = PlatformAsset(
|
val asset = PlatformAsset(
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
|
|
|
||||||
|
|
@ -133,8 +133,9 @@ class DriftTrashedLocalAssetRepository extends DriftDatabaseRepository {
|
||||||
albumId: item.albumId,
|
albumId: item.albumId,
|
||||||
name: item.asset.name,
|
name: item.asset.name,
|
||||||
type: item.asset.type,
|
type: item.asset.type,
|
||||||
checksum: effectiveChecksum == null ? const Value.absent() : Value(effectiveChecksum),
|
checksum: Value(effectiveChecksum),
|
||||||
createdAt: Value(item.asset.createdAt),
|
createdAt: Value(item.asset.createdAt),
|
||||||
|
updatedAt: Value(item.asset.updatedAt),
|
||||||
width: Value(item.asset.width),
|
width: Value(item.asset.width),
|
||||||
height: Value(item.asset.height),
|
height: Value(item.asset.height),
|
||||||
durationInSeconds: Value(item.asset.durationInSeconds),
|
durationInSeconds: Value(item.asset.durationInSeconds),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue