mirror of
https://github.com/immich-app/immich.git
synced 2026-01-25 21:27:42 -05:00
* feat(trash_sync): do not restore assets deleted locally only small fixes * feat(trash_sync): revert tag name * feat(trash_sync): resolve merge conflicts * refactor(trash_sync): consolidate local asset deletion logic * feat(mobile): Add TrashOrigin enum Replace isRestorable to sourse change related logic in repo * feat(mobile): fix format * fix(mobile): fix restoration scope * fix(mobile): Add coverage for ActionService deleteLocal paths Update LocalSyncService tests Set default value for source column * fix(mobile): db - require trash origin and update drift schema --------- Co-authored-by: Peter Ombodi <peter.ombodi@gmail.com>
50 lines
1.6 KiB
Dart
50 lines
1.6 KiB
Dart
import 'package:drift/drift.dart';
|
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
|
import 'package:immich_mobile/infrastructure/entities/trashed_local_asset.entity.drift.dart';
|
|
import 'package:immich_mobile/infrastructure/utils/asset.mixin.dart';
|
|
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
|
|
|
enum TrashOrigin {
|
|
// do not change this order!
|
|
localSync,
|
|
remoteSync,
|
|
localUser,
|
|
}
|
|
|
|
@TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)')
|
|
@TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_album ON trashed_local_asset_entity (album_id)')
|
|
class TrashedLocalAssetEntity extends Table with DriftDefaultsMixin, AssetEntityMixin {
|
|
const TrashedLocalAssetEntity();
|
|
|
|
TextColumn get id => text()();
|
|
|
|
TextColumn get albumId => text()();
|
|
|
|
TextColumn get checksum => text().nullable()();
|
|
|
|
BoolColumn get isFavorite => boolean().withDefault(const Constant(false))();
|
|
|
|
IntColumn get orientation => integer().withDefault(const Constant(0))();
|
|
|
|
IntColumn get source => intEnum<TrashOrigin>()();
|
|
|
|
@override
|
|
Set<Column> get primaryKey => {id, albumId};
|
|
}
|
|
|
|
extension TrashedLocalAssetEntityDataDomainExtension on TrashedLocalAssetEntityData {
|
|
LocalAsset toLocalAsset() => LocalAsset(
|
|
id: id,
|
|
name: name,
|
|
checksum: checksum,
|
|
type: type,
|
|
createdAt: createdAt,
|
|
updatedAt: updatedAt,
|
|
durationInSeconds: durationInSeconds,
|
|
isFavorite: isFavorite,
|
|
height: height,
|
|
width: width,
|
|
orientation: orientation,
|
|
);
|
|
}
|