Add support for early validation of photo
Signed-off-by: Neeraj Gupta <254676+ua741@users.noreply.github.com>
This commit is contained in:
parent
094da58492
commit
d833ba31ed
|
@ -128,6 +128,18 @@ class FileUpdationDB {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if entry existing for given localID and reason
|
||||||
|
Future<bool> isExisting(String localID, String reason) async {
|
||||||
|
final db = await instance.database;
|
||||||
|
final String whereClause =
|
||||||
|
'$columnLocalID = "$localID" AND $columnReason = "$reason"';
|
||||||
|
final rows = await db.query(
|
||||||
|
tableName,
|
||||||
|
where: whereClause,
|
||||||
|
);
|
||||||
|
return rows.isNotEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<String>> getLocalIDsForPotentialReUpload(
|
Future<List<String>> getLocalIDsForPotentialReUpload(
|
||||||
int limit,
|
int limit,
|
||||||
String reason,
|
String reason,
|
||||||
|
|
|
@ -9,6 +9,7 @@ import 'package:photos/db/file_updation_db.dart';
|
||||||
import 'package:photos/db/files_db.dart';
|
import 'package:photos/db/files_db.dart';
|
||||||
import "package:photos/extensions/list.dart";
|
import "package:photos/extensions/list.dart";
|
||||||
import "package:photos/extensions/stop_watch.dart";
|
import "package:photos/extensions/stop_watch.dart";
|
||||||
|
import "package:photos/models/file/extensions/file_props.dart";
|
||||||
import 'package:photos/models/file/file.dart';
|
import 'package:photos/models/file/file.dart';
|
||||||
import 'package:photos/models/file/file_type.dart';
|
import 'package:photos/models/file/file_type.dart';
|
||||||
import "package:photos/services/files_service.dart";
|
import "package:photos/services/files_service.dart";
|
||||||
|
@ -209,6 +210,27 @@ class LocalFileUpdateService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> checkLivePhoto(EnteFile file) async {
|
||||||
|
if (file.localID == null ||
|
||||||
|
file.localID!.isEmpty ||
|
||||||
|
!file.isUploaded ||
|
||||||
|
file.fileType != FileType.livePhoto ||
|
||||||
|
!file.isOwner) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_prefs.containsKey(_iosLivePhotoSizeMigrationDone)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool hasEntry = await _fileUpdationDB.isExisting(
|
||||||
|
file.localID!,
|
||||||
|
FileUpdationDB.livePhotoCheck,
|
||||||
|
);
|
||||||
|
if (hasEntry) {
|
||||||
|
_logger.info('eager checkLivePhoto ${file.tag}');
|
||||||
|
await _checkLivePhotoWithLowOrUnknownSize([file.localID!]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _handleLivePhotosSizedCheck() async {
|
Future<void> _handleLivePhotosSizedCheck() async {
|
||||||
try {
|
try {
|
||||||
if (_prefs.containsKey(_iosLivePhotoSizeMigrationDone)) {
|
if (_prefs.containsKey(_iosLivePhotoSizeMigrationDone)) {
|
||||||
|
@ -226,12 +248,15 @@ class LocalFileUpdateService {
|
||||||
FileUpdationDB.livePhotoCheck,
|
FileUpdationDB.livePhotoCheck,
|
||||||
);
|
);
|
||||||
if (localIDsToProcess.isNotEmpty) {
|
if (localIDsToProcess.isNotEmpty) {
|
||||||
final chunks = localIDsToProcess.chunks(10);
|
final chunksOf50 = localIDsToProcess.chunks(50);
|
||||||
for (final chunk in chunks) {
|
for (final chunk in chunksOf50) {
|
||||||
final sTime = DateTime.now().microsecondsSinceEpoch;
|
final sTime = DateTime.now().microsecondsSinceEpoch;
|
||||||
await _checkLivePhotoWithLowOrUnknownSize(
|
final List<Future> futures = [];
|
||||||
chunk,
|
final chunkOf10 = chunk.chunks(10);
|
||||||
);
|
for (final smallChunk in chunkOf10) {
|
||||||
|
futures.add(_checkLivePhotoWithLowOrUnknownSize(smallChunk));
|
||||||
|
}
|
||||||
|
await Future.wait(futures);
|
||||||
final eTime = DateTime.now().microsecondsSinceEpoch;
|
final eTime = DateTime.now().microsecondsSinceEpoch;
|
||||||
final d = Duration(microseconds: eTime - sTime);
|
final d = Duration(microseconds: eTime - sTime);
|
||||||
_logger.info(
|
_logger.info(
|
||||||
|
|
|
@ -10,6 +10,7 @@ import "package:photos/models/file/extensions/file_props.dart";
|
||||||
import 'package:photos/models/file/file.dart';
|
import 'package:photos/models/file/file.dart';
|
||||||
import "package:photos/models/metadata/file_magic.dart";
|
import "package:photos/models/metadata/file_magic.dart";
|
||||||
import "package:photos/services/file_magic_service.dart";
|
import "package:photos/services/file_magic_service.dart";
|
||||||
|
import "package:photos/services/local_file_update_service.dart";
|
||||||
import 'package:photos/ui/viewer/file/zoomable_image.dart';
|
import 'package:photos/ui/viewer/file/zoomable_image.dart';
|
||||||
import 'package:photos/utils/file_util.dart';
|
import 'package:photos/utils/file_util.dart';
|
||||||
import 'package:photos/utils/toast_util.dart';
|
import 'package:photos/utils/toast_util.dart';
|
||||||
|
@ -46,6 +47,9 @@ class _ZoomableLiveImageNewState extends State<ZoomableLiveImageNew>
|
||||||
_logger.info(
|
_logger.info(
|
||||||
'initState for ${_enteFile.generatedID} with tag ${_enteFile.tag} and name ${_enteFile.displayName}',
|
'initState for ${_enteFile.generatedID} with tag ${_enteFile.tag} and name ${_enteFile.displayName}',
|
||||||
);
|
);
|
||||||
|
if (_enteFile.isLivePhoto && _enteFile.isUploaded) {
|
||||||
|
LocalFileUpdateService.instance.checkLivePhoto(_enteFile).ignore();
|
||||||
|
}
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue