mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 20:25:32 -04:00
server: add originalFileName to SyncAssetV1
This commit is contained in:
parent
b44cfe5d1c
commit
3e5a944143
@ -165,7 +165,7 @@ class DriftSyncStreamRepository extends DriftDatabaseRepository
|
|||||||
_db.batch((batch) {
|
_db.batch((batch) {
|
||||||
for (final asset in data) {
|
for (final asset in data) {
|
||||||
final companion = RemoteAssetEntityCompanion(
|
final companion = RemoteAssetEntityCompanion(
|
||||||
name: const Value(''), // TODO: Needed from the server
|
name: Value(asset.originalFileName),
|
||||||
type: Value(asset.type.toAssetType()),
|
type: Value(asset.type.toAssetType()),
|
||||||
createdAt: Value.absentIfNull(asset.fileCreatedAt),
|
createdAt: Value.absentIfNull(asset.fileCreatedAt),
|
||||||
updatedAt: Value.absentIfNull(asset.fileModifiedAt),
|
updatedAt: Value.absentIfNull(asset.fileModifiedAt),
|
||||||
|
10
mobile/openapi/lib/model/sync_asset_v1.dart
generated
10
mobile/openapi/lib/model/sync_asset_v1.dart
generated
@ -21,6 +21,7 @@ class SyncAssetV1 {
|
|||||||
required this.isFavorite,
|
required this.isFavorite,
|
||||||
required this.isVisible,
|
required this.isVisible,
|
||||||
required this.localDateTime,
|
required this.localDateTime,
|
||||||
|
required this.originalFileName,
|
||||||
required this.ownerId,
|
required this.ownerId,
|
||||||
required this.thumbhash,
|
required this.thumbhash,
|
||||||
required this.type,
|
required this.type,
|
||||||
@ -42,6 +43,8 @@ class SyncAssetV1 {
|
|||||||
|
|
||||||
DateTime? localDateTime;
|
DateTime? localDateTime;
|
||||||
|
|
||||||
|
String originalFileName;
|
||||||
|
|
||||||
String ownerId;
|
String ownerId;
|
||||||
|
|
||||||
String? thumbhash;
|
String? thumbhash;
|
||||||
@ -58,6 +61,7 @@ class SyncAssetV1 {
|
|||||||
other.isFavorite == isFavorite &&
|
other.isFavorite == isFavorite &&
|
||||||
other.isVisible == isVisible &&
|
other.isVisible == isVisible &&
|
||||||
other.localDateTime == localDateTime &&
|
other.localDateTime == localDateTime &&
|
||||||
|
other.originalFileName == originalFileName &&
|
||||||
other.ownerId == ownerId &&
|
other.ownerId == ownerId &&
|
||||||
other.thumbhash == thumbhash &&
|
other.thumbhash == thumbhash &&
|
||||||
other.type == type;
|
other.type == type;
|
||||||
@ -73,12 +77,13 @@ class SyncAssetV1 {
|
|||||||
(isFavorite.hashCode) +
|
(isFavorite.hashCode) +
|
||||||
(isVisible.hashCode) +
|
(isVisible.hashCode) +
|
||||||
(localDateTime == null ? 0 : localDateTime!.hashCode) +
|
(localDateTime == null ? 0 : localDateTime!.hashCode) +
|
||||||
|
(originalFileName.hashCode) +
|
||||||
(ownerId.hashCode) +
|
(ownerId.hashCode) +
|
||||||
(thumbhash == null ? 0 : thumbhash!.hashCode) +
|
(thumbhash == null ? 0 : thumbhash!.hashCode) +
|
||||||
(type.hashCode);
|
(type.hashCode);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'SyncAssetV1[checksum=$checksum, deletedAt=$deletedAt, fileCreatedAt=$fileCreatedAt, fileModifiedAt=$fileModifiedAt, id=$id, isFavorite=$isFavorite, isVisible=$isVisible, localDateTime=$localDateTime, ownerId=$ownerId, thumbhash=$thumbhash, type=$type]';
|
String toString() => 'SyncAssetV1[checksum=$checksum, deletedAt=$deletedAt, fileCreatedAt=$fileCreatedAt, fileModifiedAt=$fileModifiedAt, id=$id, isFavorite=$isFavorite, isVisible=$isVisible, localDateTime=$localDateTime, originalFileName=$originalFileName, ownerId=$ownerId, thumbhash=$thumbhash, type=$type]';
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final json = <String, dynamic>{};
|
final json = <String, dynamic>{};
|
||||||
@ -106,6 +111,7 @@ class SyncAssetV1 {
|
|||||||
} else {
|
} else {
|
||||||
// json[r'localDateTime'] = null;
|
// json[r'localDateTime'] = null;
|
||||||
}
|
}
|
||||||
|
json[r'originalFileName'] = this.originalFileName;
|
||||||
json[r'ownerId'] = this.ownerId;
|
json[r'ownerId'] = this.ownerId;
|
||||||
if (this.thumbhash != null) {
|
if (this.thumbhash != null) {
|
||||||
json[r'thumbhash'] = this.thumbhash;
|
json[r'thumbhash'] = this.thumbhash;
|
||||||
@ -133,6 +139,7 @@ class SyncAssetV1 {
|
|||||||
isFavorite: mapValueOfType<bool>(json, r'isFavorite')!,
|
isFavorite: mapValueOfType<bool>(json, r'isFavorite')!,
|
||||||
isVisible: mapValueOfType<bool>(json, r'isVisible')!,
|
isVisible: mapValueOfType<bool>(json, r'isVisible')!,
|
||||||
localDateTime: mapDateTime(json, r'localDateTime', r''),
|
localDateTime: mapDateTime(json, r'localDateTime', r''),
|
||||||
|
originalFileName: mapValueOfType<String>(json, r'originalFileName')!,
|
||||||
ownerId: mapValueOfType<String>(json, r'ownerId')!,
|
ownerId: mapValueOfType<String>(json, r'ownerId')!,
|
||||||
thumbhash: mapValueOfType<String>(json, r'thumbhash'),
|
thumbhash: mapValueOfType<String>(json, r'thumbhash'),
|
||||||
type: SyncAssetV1TypeEnum.fromJson(json[r'type'])!,
|
type: SyncAssetV1TypeEnum.fromJson(json[r'type'])!,
|
||||||
@ -191,6 +198,7 @@ class SyncAssetV1 {
|
|||||||
'isFavorite',
|
'isFavorite',
|
||||||
'isVisible',
|
'isVisible',
|
||||||
'localDateTime',
|
'localDateTime',
|
||||||
|
'originalFileName',
|
||||||
'ownerId',
|
'ownerId',
|
||||||
'thumbhash',
|
'thumbhash',
|
||||||
'type',
|
'type',
|
||||||
|
@ -12234,6 +12234,9 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"originalFileName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"ownerId": {
|
"ownerId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@ -12260,6 +12263,7 @@
|
|||||||
"isFavorite",
|
"isFavorite",
|
||||||
"isVisible",
|
"isVisible",
|
||||||
"localDateTime",
|
"localDateTime",
|
||||||
|
"originalFileName",
|
||||||
"ownerId",
|
"ownerId",
|
||||||
"thumbhash",
|
"thumbhash",
|
||||||
"type"
|
"type"
|
||||||
|
@ -326,6 +326,7 @@ export const columns = {
|
|||||||
syncAsset: [
|
syncAsset: [
|
||||||
'id',
|
'id',
|
||||||
'ownerId',
|
'ownerId',
|
||||||
|
'originalFileName',
|
||||||
'thumbhash',
|
'thumbhash',
|
||||||
'checksum',
|
'checksum',
|
||||||
'fileCreatedAt',
|
'fileCreatedAt',
|
||||||
|
@ -59,6 +59,7 @@ export class SyncPartnerDeleteV1 {
|
|||||||
export class SyncAssetV1 {
|
export class SyncAssetV1 {
|
||||||
id!: string;
|
id!: string;
|
||||||
ownerId!: string;
|
ownerId!: string;
|
||||||
|
originalFileName!: string;
|
||||||
thumbhash!: string | null;
|
thumbhash!: string | null;
|
||||||
checksum!: string;
|
checksum!: string;
|
||||||
fileCreatedAt!: Date | null;
|
fileCreatedAt!: Date | null;
|
||||||
|
@ -76,6 +76,7 @@ order by
|
|||||||
select
|
select
|
||||||
"id",
|
"id",
|
||||||
"ownerId",
|
"ownerId",
|
||||||
|
"originalFileName",
|
||||||
"thumbhash",
|
"thumbhash",
|
||||||
"checksum",
|
"checksum",
|
||||||
"fileCreatedAt",
|
"fileCreatedAt",
|
||||||
@ -98,6 +99,7 @@ order by
|
|||||||
select
|
select
|
||||||
"id",
|
"id",
|
||||||
"ownerId",
|
"ownerId",
|
||||||
|
"originalFileName",
|
||||||
"thumbhash",
|
"thumbhash",
|
||||||
"checksum",
|
"checksum",
|
||||||
"fileCreatedAt",
|
"fileCreatedAt",
|
||||||
|
@ -424,12 +424,14 @@ describe(SyncService.name, () => {
|
|||||||
it('should detect and sync the first asset', async () => {
|
it('should detect and sync the first asset', async () => {
|
||||||
const { auth, sut, getRepository, testSync } = await setup();
|
const { auth, sut, getRepository, testSync } = await setup();
|
||||||
|
|
||||||
|
const originalFileName = 'firstAsset';
|
||||||
const checksum = '1115vHcVkZzNp3Q9G+FEA0nu6zUbGb4Tj4UOXkN0wRA=';
|
const checksum = '1115vHcVkZzNp3Q9G+FEA0nu6zUbGb4Tj4UOXkN0wRA=';
|
||||||
const thumbhash = '2225vHcVkZzNp3Q9G+FEA0nu6zUbGb4Tj4UOXkN0wRA=';
|
const thumbhash = '2225vHcVkZzNp3Q9G+FEA0nu6zUbGb4Tj4UOXkN0wRA=';
|
||||||
const date = new Date().toISOString();
|
const date = new Date().toISOString();
|
||||||
|
|
||||||
const assetRepo = getRepository('asset');
|
const assetRepo = getRepository('asset');
|
||||||
const asset = mediumFactory.assetInsert({
|
const asset = mediumFactory.assetInsert({
|
||||||
|
originalFileName,
|
||||||
ownerId: auth.user.id,
|
ownerId: auth.user.id,
|
||||||
checksum: Buffer.from(checksum, 'base64'),
|
checksum: Buffer.from(checksum, 'base64'),
|
||||||
thumbhash: Buffer.from(thumbhash, 'base64'),
|
thumbhash: Buffer.from(thumbhash, 'base64'),
|
||||||
@ -449,6 +451,7 @@ describe(SyncService.name, () => {
|
|||||||
ack: expect.any(String),
|
ack: expect.any(String),
|
||||||
data: {
|
data: {
|
||||||
id: asset.id,
|
id: asset.id,
|
||||||
|
originalFileName,
|
||||||
ownerId: asset.ownerId,
|
ownerId: asset.ownerId,
|
||||||
thumbhash,
|
thumbhash,
|
||||||
checksum,
|
checksum,
|
||||||
@ -534,6 +537,7 @@ describe(SyncService.name, () => {
|
|||||||
it('should detect and sync the first partner asset', async () => {
|
it('should detect and sync the first partner asset', async () => {
|
||||||
const { auth, sut, getRepository, testSync } = await setup();
|
const { auth, sut, getRepository, testSync } = await setup();
|
||||||
|
|
||||||
|
const originalFileName = 'firstPartnerAsset';
|
||||||
const checksum = '1115vHcVkZzNp3Q9G+FEA0nu6zUbGb4Tj4UOXkN0wRA=';
|
const checksum = '1115vHcVkZzNp3Q9G+FEA0nu6zUbGb4Tj4UOXkN0wRA=';
|
||||||
const thumbhash = '2225vHcVkZzNp3Q9G+FEA0nu6zUbGb4Tj4UOXkN0wRA=';
|
const thumbhash = '2225vHcVkZzNp3Q9G+FEA0nu6zUbGb4Tj4UOXkN0wRA=';
|
||||||
const date = new Date().toISOString();
|
const date = new Date().toISOString();
|
||||||
@ -545,6 +549,7 @@ describe(SyncService.name, () => {
|
|||||||
const assetRepo = getRepository('asset');
|
const assetRepo = getRepository('asset');
|
||||||
const asset = mediumFactory.assetInsert({
|
const asset = mediumFactory.assetInsert({
|
||||||
ownerId: user2.id,
|
ownerId: user2.id,
|
||||||
|
originalFileName,
|
||||||
checksum: Buffer.from(checksum, 'base64'),
|
checksum: Buffer.from(checksum, 'base64'),
|
||||||
thumbhash: Buffer.from(thumbhash, 'base64'),
|
thumbhash: Buffer.from(thumbhash, 'base64'),
|
||||||
fileCreatedAt: date,
|
fileCreatedAt: date,
|
||||||
@ -567,6 +572,7 @@ describe(SyncService.name, () => {
|
|||||||
data: {
|
data: {
|
||||||
id: asset.id,
|
id: asset.id,
|
||||||
ownerId: asset.ownerId,
|
ownerId: asset.ownerId,
|
||||||
|
originalFileName,
|
||||||
thumbhash,
|
thumbhash,
|
||||||
checksum,
|
checksum,
|
||||||
deletedAt: null,
|
deletedAt: null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user