simplify logic to compute useFileTimeStamp flag

This commit is contained in:
Neeraj Gupta 2022-12-08 11:09:58 +05:30
parent b392b90b8f
commit 373d0812fc
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1

View file

@ -193,17 +193,14 @@ class File extends EnteFile {
if (!hasExifTime && Platform.isAndroid && title != null) {
final timeFromFileName = parseDateTimeFromFileNameV2(title!);
if (timeFromFileName != null) {
// only use timeFromFileName is the delta between current
// creationTime and timeFromFileName is larger than some threshold.
// only use timeFromFileName if the existing creationTime and
// timeFromFilename belongs to different date.
// This is done because many times the fileTimeStamp will only give us
// the date, not time value but the photo_manager's creation time will
// contain the time.
final bool useFileTimeStamp = creationTime == null ||
daysBetween(
DateTime.fromMicrosecondsSinceEpoch(creationTime!),
timeFromFileName,
).abs() >
2;
!areFromSameDay(
creationTime!, timeFromFileName.microsecondsSinceEpoch);
if (useFileTimeStamp) {
creationTime = timeFromFileName.microsecondsSinceEpoch;
}