immich/mobile/lib/infrastructure/entities/trashed_local_asset.entity.dart
Peter Ombodi f7e5288173 rework trashed assets handling
- add new table trashed_local_asset
- mirror trashed assets data in trashed_local_asset.
- compute checksums for assets trashed out-of-app.
- restore assets present in trashed_local_asset and non-trashed in remote_asset.
- simplify moving-to-trash logic based on remote_asset events.
2025-09-18 13:55:56 +03:00

42 lines
1.3 KiB
Dart

import 'package:drift/drift.dart';
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
import 'package:immich_mobile/domain/models/asset/trashed_asset.model.dart';
import 'package:immich_mobile/infrastructure/entities/trashed_local_asset.entity.drift.dart';
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
@TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)')
class TrashedLocalAssetEntity extends Table with DriftDefaultsMixin {
const TrashedLocalAssetEntity();
TextColumn get id => text()();
TextColumn get albumId => text()();
TextColumn get checksum => text().nullable()();
TextColumn get name => text()();
IntColumn get type => intEnum<AssetType>()();
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
IntColumn get size => integer().nullable()();
@override
Set<Column> get primaryKey => {id};
}
extension TrashedLocalAssetEntityDataDomainExtension on TrashedLocalAssetEntityData {
TrashedAsset toDto(String albumId) => TrashedAsset(
id: id,
name: name,
albumId: albumId,
checksum: checksum,
type: type,
createdAt: createdAt,
updatedAt: updatedAt,
size: size,
);
}