mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Fix not updating bestDateTime when updating file property
This commit is contained in:
parent
054d6bbae5
commit
037fbd845d
3 changed files with 23 additions and 5 deletions
|
@ -6,6 +6,7 @@ import 'package:nc_photos/account.dart';
|
|||
import 'package:nc_photos/ci_string.dart';
|
||||
import 'package:nc_photos/entity/exif.dart';
|
||||
import 'package:nc_photos/entity/file_descriptor.dart';
|
||||
import 'package:nc_photos/entity/file_util.dart' as file_util;
|
||||
import 'package:nc_photos/json_util.dart' as json_util;
|
||||
import 'package:nc_photos/or_null.dart';
|
||||
import 'package:nc_photos/string_extension.dart';
|
||||
|
@ -568,11 +569,11 @@ class File with EquatableMixin implements FileDescriptor {
|
|||
}
|
||||
|
||||
extension FileExtension on File {
|
||||
DateTime get bestDateTime =>
|
||||
overrideDateTime ??
|
||||
metadata?.exif?.dateTimeOriginal ??
|
||||
lastModified ??
|
||||
DateTime.now().toUtc();
|
||||
DateTime get bestDateTime => file_util.getBestDateTime(
|
||||
overrideDateTime: overrideDateTime,
|
||||
dateTimeOriginal: metadata?.exif?.dateTimeOriginal,
|
||||
lastModified: lastModified,
|
||||
);
|
||||
|
||||
bool isOwned(CiString userId) => ownerId == null || ownerId == userId;
|
||||
}
|
||||
|
|
|
@ -469,6 +469,17 @@ class FileSqliteDbDataSource implements FileDataSource {
|
|||
: sql.Value(overrideDateTime.obj),
|
||||
isFavorite:
|
||||
favorite == null ? const sql.Value.absent() : sql.Value(favorite),
|
||||
bestDateTime: overrideDateTime == null && metadata == null
|
||||
? const sql.Value.absent()
|
||||
: sql.Value(file_util.getBestDateTime(
|
||||
overrideDateTime: overrideDateTime == null
|
||||
? f.overrideDateTime
|
||||
: overrideDateTime.obj,
|
||||
dateTimeOriginal: metadata == null
|
||||
? f.metadata?.exif?.dateTimeOriginal
|
||||
: metadata.obj?.exif?.dateTimeOriginal,
|
||||
lastModified: f.lastModified,
|
||||
)),
|
||||
);
|
||||
await (db.update(db.accountFiles)
|
||||
..where((t) => t.rowId.equals(rowIds.accountFileRowId)))
|
||||
|
|
|
@ -96,6 +96,12 @@ bool isMissingMetadata(File file) =>
|
|||
isSupportedImageFormat(file) &&
|
||||
(file.metadata == null || file.location == null);
|
||||
|
||||
DateTime getBestDateTime({
|
||||
DateTime? overrideDateTime,
|
||||
DateTime? dateTimeOriginal,
|
||||
DateTime? lastModified,
|
||||
}) => overrideDateTime ?? dateTimeOriginal ?? lastModified ?? DateTime.now().toUtc();
|
||||
|
||||
final supportedFormatMimes = [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
|
|
Loading…
Reference in a new issue