[mob][photos] Use modificationTime as creationTime if it's lower than… (#1451)

… creationTime

## Description

## Tests
This commit is contained in:
Neeraj Gupta 2024-04-15 16:40:59 +05:30 committed by GitHub
commit 61f05f8eff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -85,13 +85,24 @@ class EnteFile {
static int parseFileCreationTime(String? fileTitle, AssetEntity asset) {
int creationTime = asset.createDateTime.microsecondsSinceEpoch;
final int modificationTime = asset.modifiedDateTime.microsecondsSinceEpoch;
if (creationTime >= jan011981Time) {
// assuming that fileSystem is returning correct creationTime.
// During upload, this might get overridden with exif Creation time
// When the assetModifiedTime is less than creationTime, than just use
// that as creationTime. This is to handle cases where file might be
// copied to the fileSystem from somewhere else See #https://superuser.com/a/1091147
if (modificationTime >= jan011981Time &&
modificationTime < creationTime) {
_logger.info(
'LocalID: ${asset.id} modification time is less than creation time. Using modification time as creation time',
);
creationTime = modificationTime;
}
return creationTime;
} else {
if (asset.modifiedDateTime.microsecondsSinceEpoch >= jan011981Time) {
creationTime = asset.modifiedDateTime.microsecondsSinceEpoch;
if (modificationTime >= jan011981Time) {
creationTime = modificationTime;
} else {
creationTime = DateTime.now().toUtc().microsecondsSinceEpoch;
}
@ -106,7 +117,6 @@ class EnteFile {
// ignore
}
}
return creationTime;
}