mirror of
https://github.com/ente-io/ente.git
synced 2025-08-13 01:27:17 +00:00
[mob][photos] Check and remove old models
This commit is contained in:
@@ -9,6 +9,8 @@ import "package:photos/core/network/network.dart";
|
|||||||
class RemoteAssetsService {
|
class RemoteAssetsService {
|
||||||
static final _logger = Logger("RemoteAssetsService");
|
static final _logger = Logger("RemoteAssetsService");
|
||||||
|
|
||||||
|
bool checkRemovedOldAssets = false;
|
||||||
|
|
||||||
RemoteAssetsService._privateConstructor();
|
RemoteAssetsService._privateConstructor();
|
||||||
final StreamController<(String, int, int)> _progressController =
|
final StreamController<(String, int, int)> _progressController =
|
||||||
StreamController<(String, int, int)>.broadcast();
|
StreamController<(String, int, int)>.broadcast();
|
||||||
@@ -33,6 +35,7 @@ class RemoteAssetsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getAssetPath(String remotePath, {bool refetch = false}) async {
|
Future<String> getAssetPath(String remotePath, {bool refetch = false}) async {
|
||||||
|
await cleanupOldModelsIfNeeded();
|
||||||
final file = await getAsset(remotePath, refetch: refetch);
|
final file = await getAsset(remotePath, refetch: refetch);
|
||||||
return file.path;
|
return file.path;
|
||||||
}
|
}
|
||||||
@@ -112,4 +115,28 @@ class RemoteAssetsService {
|
|||||||
|
|
||||||
_logger.info("Downloaded " + url);
|
_logger.info("Downloaded " + url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> cleanupOldModelsIfNeeded() async {
|
||||||
|
if (checkRemovedOldAssets) return;
|
||||||
|
const oldModelNames = [
|
||||||
|
"https://models.ente.io/clip-image-vit-32-float32.onnx",
|
||||||
|
"https://models.ente.io/clip-text-vit-32-uint8.onnx",
|
||||||
|
"https://models.ente.io/mobileclip_s2_image.onnx",
|
||||||
|
"https://models.ente.io/mobileclip_s2_image_opset18_rgba_sim.onnx",
|
||||||
|
"https://models.ente.io/mobileclip_s2_text_int32.onnx",
|
||||||
|
"https://models.ente.io/yolov5s_face_640_640_dynamic.onnx",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (final remotePath in oldModelNames) {
|
||||||
|
final localPath = await _getLocalPath(remotePath);
|
||||||
|
if (File(localPath).existsSync()) {
|
||||||
|
_logger.info(
|
||||||
|
'Removing unused ML model ${remotePath.split('/').last} at $localPath',
|
||||||
|
);
|
||||||
|
await File(localPath).delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkRemovedOldAssets = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user