Remove the prints
This commit is contained in:
@@ -45,14 +45,12 @@ class _TripCardState extends State<TripCard> {
|
||||
});
|
||||
|
||||
try {
|
||||
print('TripCard: Tentative de chargement d\'image pour ${widget.trip.location}');
|
||||
|
||||
// D'abord vérifier si une image existe déjà dans le Storage
|
||||
String? imageUrl = await _placeImageService.getExistingImageUrl(widget.trip.location);
|
||||
|
||||
// Si aucune image n'existe, en télécharger une nouvelle
|
||||
if (imageUrl == null) {
|
||||
print('TripCard: Aucune image existante, téléchargement via Google Places...');
|
||||
imageUrl = await _placeImageService.getPlaceImageUrl(widget.trip.location);
|
||||
}
|
||||
|
||||
@@ -64,14 +62,12 @@ class _TripCardState extends State<TripCard> {
|
||||
|
||||
// Mettre à jour le voyage dans la base de données avec l'imageUrl
|
||||
_updateTripWithImage(imageUrl);
|
||||
print('TripCard: Image chargée avec succès: $imageUrl');
|
||||
} else {
|
||||
setState(() {
|
||||
_isLoadingImage = false;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
print('TripCard: Erreur lors du chargement de l\'image: $e');
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoadingImage = false;
|
||||
@@ -91,10 +87,8 @@ class _TripCardState extends State<TripCard> {
|
||||
|
||||
// Mettre à jour dans la base de données
|
||||
await _tripRepository.updateTrip(widget.trip.id!, updatedTrip);
|
||||
print('TripCard: Voyage mis à jour avec la nouvelle image dans la base de données');
|
||||
}
|
||||
} catch (e) {
|
||||
print('TripCard: Erreur lors de la mise à jour du voyage: $e');
|
||||
// En cas d'erreur, on continue sans échec - l'image reste affichée localement
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,20 +11,16 @@ class PlaceImageService {
|
||||
|
||||
/// Récupère l'URL de l'image d'un lieu depuis Google Places API
|
||||
Future<String?> getPlaceImageUrl(String location) async {
|
||||
print('PlaceImageService: Tentative de récupération d\'image pour: $location');
|
||||
|
||||
try {
|
||||
// ÉTAPE 1: Vérifier d'abord si une image existe déjà dans le Storage
|
||||
final existingUrl = await _checkExistingImage(location);
|
||||
if (existingUrl != null) {
|
||||
print('PlaceImageService: Image existante trouvée dans le Storage: $existingUrl');
|
||||
return existingUrl;
|
||||
}
|
||||
|
||||
print('PlaceImageService: Aucune image existante, recherche via Google Places API...');
|
||||
|
||||
if (_apiKey.isEmpty) {
|
||||
print('PlaceImageService: Erreur - Google Maps API key manquante');
|
||||
_errorService.logError('PlaceImageService', 'Google Maps API key manquante');
|
||||
return null;
|
||||
}
|
||||
@@ -33,33 +29,27 @@ class PlaceImageService {
|
||||
final searchTerms = _generateSearchTerms(location);
|
||||
|
||||
for (final searchTerm in searchTerms) {
|
||||
print('PlaceImageService: Essai avec terme de recherche: $searchTerm');
|
||||
|
||||
// 1. Rechercher le lieu
|
||||
final placeId = await _getPlaceIdForTerm(searchTerm);
|
||||
if (placeId == null) continue;
|
||||
|
||||
print('PlaceImageService: Place ID trouvé: $placeId');
|
||||
|
||||
// 2. Récupérer les détails du lieu avec les photos
|
||||
final photoReference = await _getPhotoReference(placeId);
|
||||
if (photoReference == null) continue;
|
||||
|
||||
print('PlaceImageService: Photo référence trouvée: $photoReference');
|
||||
|
||||
// 3. Télécharger et sauvegarder l'image (seulement si pas d'image existante)
|
||||
final imageUrl = await _downloadAndSaveImage(photoReference, location);
|
||||
if (imageUrl != null) {
|
||||
print('PlaceImageService: Image URL finale: $imageUrl');
|
||||
return imageUrl;
|
||||
}
|
||||
}
|
||||
|
||||
print('PlaceImageService: Aucune image trouvée pour tous les termes de recherche');
|
||||
return null;
|
||||
|
||||
} catch (e) {
|
||||
print('PlaceImageService: Erreur lors de la récupération de l\'image: $e');
|
||||
_errorService.logError('PlaceImageService', 'Erreur lors de la récupération de l\'image: $e');
|
||||
return null;
|
||||
}
|
||||
@@ -178,7 +168,6 @@ class PlaceImageService {
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
print('PlaceImageService: Erreur recherche avec type $type: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -205,7 +194,6 @@ class PlaceImageService {
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
print('PlaceImageService: Erreur recherche générale: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -296,7 +284,6 @@ class PlaceImageService {
|
||||
'&photo_reference=$photoReference'
|
||||
'&key=$_apiKey';
|
||||
|
||||
print('PlaceImageService: Téléchargement de l\'image: $imageUrl');
|
||||
|
||||
// Télécharger l'image
|
||||
final response = await http.get(Uri.parse(imageUrl));
|
||||
@@ -325,14 +312,11 @@ class PlaceImageService {
|
||||
|
||||
// Récupérer l'URL de téléchargement
|
||||
final downloadUrl = await uploadTask.ref.getDownloadURL();
|
||||
print('PlaceImageService: Image sauvegardée avec succès: $downloadUrl');
|
||||
return downloadUrl;
|
||||
} else {
|
||||
print('PlaceImageService: Erreur HTTP ${response.statusCode} lors du téléchargement');
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
print('PlaceImageService: Erreur lors du téléchargement/sauvegarde: $e');
|
||||
_errorService.logError('PlaceImageService', 'Erreur lors du téléchargement/sauvegarde: $e');
|
||||
return null;
|
||||
}
|
||||
@@ -342,7 +326,6 @@ class PlaceImageService {
|
||||
Future<String?> _checkExistingImage(String location) async {
|
||||
try {
|
||||
final normalizedLocation = _normalizeLocationName(location);
|
||||
print('PlaceImageService: Recherche d\'image existante pour "$location" (normalisé: "$normalizedLocation")');
|
||||
|
||||
final listResult = await _storage.ref('trip_images').listAll();
|
||||
|
||||
@@ -355,7 +338,6 @@ class PlaceImageService {
|
||||
// Méthode 1: Vérifier avec la location normalisée (nouvelles images)
|
||||
if (storedNormalizedLocation != null && storedNormalizedLocation == normalizedLocation) {
|
||||
final url = await item.getDownloadURL();
|
||||
print('PlaceImageService: Image trouvée via normalizedLocation: $url');
|
||||
return url;
|
||||
}
|
||||
|
||||
@@ -364,7 +346,6 @@ class PlaceImageService {
|
||||
final storedLocationNormalized = _normalizeLocationName(storedLocation);
|
||||
if (storedLocationNormalized == normalizedLocation) {
|
||||
final url = await item.getDownloadURL();
|
||||
print('PlaceImageService: Image trouvée via location originale: $url');
|
||||
return url;
|
||||
}
|
||||
}
|
||||
@@ -375,21 +356,17 @@ class PlaceImageService {
|
||||
if (fileName.toLowerCase().contains(normalizedLocation.toLowerCase())) {
|
||||
try {
|
||||
final url = await item.getDownloadURL();
|
||||
print('PlaceImageService: Image trouvée via nom de fichier: $url');
|
||||
return url;
|
||||
} catch (urlError) {
|
||||
print('PlaceImageService: Erreur récupération URL pour ${item.name}: $urlError');
|
||||
_errorService.logError('PlaceImageService', 'Erreur lors de la récupération de l\'URL: $urlError');
|
||||
}
|
||||
}
|
||||
|
||||
print('PlaceImageService: Impossible de lire les métadonnées pour ${item.name}: $e');
|
||||
}
|
||||
}
|
||||
|
||||
print('PlaceImageService: Aucune image existante trouvée pour "$location"');
|
||||
return null;
|
||||
} catch (e) {
|
||||
print('PlaceImageService: Erreur lors de la vérification d\'images existantes: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -406,7 +383,6 @@ class PlaceImageService {
|
||||
/// Nettoie les images inutilisées (à appeler manuellement si nécessaire)
|
||||
Future<void> cleanupUnusedImages(List<String> usedImageUrls) async {
|
||||
try {
|
||||
print('PlaceImageService: Nettoyage des images inutilisées...');
|
||||
final listResult = await _storage.ref('trip_images').listAll();
|
||||
int deletedCount = 0;
|
||||
|
||||
@@ -417,16 +393,13 @@ class PlaceImageService {
|
||||
if (!usedImageUrls.contains(url)) {
|
||||
await item.delete();
|
||||
deletedCount++;
|
||||
print('PlaceImageService: Image supprimée: ${item.name}');
|
||||
}
|
||||
} catch (e) {
|
||||
print('PlaceImageService: Erreur lors de la suppression de ${item.name}: $e');
|
||||
_errorService.logError('PlaceImageService', 'Erreur lors du nettoyage: $e');
|
||||
}
|
||||
}
|
||||
|
||||
print('PlaceImageService: Nettoyage terminé. $deletedCount images supprimées.');
|
||||
} catch (e) {
|
||||
print('PlaceImageService: Erreur lors du nettoyage: $e');
|
||||
_errorService.logError('PlaceImageService', 'Erreur lors du nettoyage: $e');
|
||||
}
|
||||
}
|
||||
@@ -434,7 +407,6 @@ class PlaceImageService {
|
||||
/// Nettoie spécifiquement les doublons d'images pour la même location
|
||||
Future<void> cleanupDuplicateImages() async {
|
||||
try {
|
||||
print('PlaceImageService: Nettoyage des images en doublon...');
|
||||
final listResult = await _storage.ref('trip_images').listAll();
|
||||
|
||||
// Grouper les images par location normalisée
|
||||
@@ -482,7 +454,6 @@ class PlaceImageService {
|
||||
final images = entry.value;
|
||||
|
||||
if (images.length > 1) {
|
||||
print('PlaceImageService: Doublons trouvés pour "$location": ${images.length} images');
|
||||
|
||||
// Trier par timestamp (garder le plus récent)
|
||||
images.sort((a, b) {
|
||||
@@ -496,19 +467,15 @@ class PlaceImageService {
|
||||
try {
|
||||
await images[i].delete();
|
||||
deletedCount++;
|
||||
print('PlaceImageService: Doublon supprimé: ${images[i].name}');
|
||||
} catch (e) {
|
||||
print('PlaceImageService: Erreur suppression ${images[i].name}: $e');
|
||||
_errorService.logError('PlaceImageService', 'Erreur lors de la suppression du doublon: $e');
|
||||
}
|
||||
}
|
||||
|
||||
print('PlaceImageService: Gardé: ${images[0].name} (plus récent)');
|
||||
}
|
||||
}
|
||||
|
||||
print('PlaceImageService: Nettoyage des doublons terminé. $deletedCount images supprimées.');
|
||||
} catch (e) {
|
||||
print('PlaceImageService: Erreur lors du nettoyage des doublons: $e');
|
||||
_errorService.logError('PlaceImageService', 'Erreur lors du nettoyage des doublons: $e');
|
||||
}
|
||||
}
|
||||
@@ -526,16 +493,12 @@ class PlaceImageService {
|
||||
/// Récupère uniquement l'URL d'une image existante dans le Storage (sans télécharger)
|
||||
Future<String?> getExistingImageUrl(String location) async {
|
||||
try {
|
||||
print('PlaceImageService: Recherche d\'image existante pour: $location');
|
||||
final existingUrl = await _checkExistingImage(location);
|
||||
if (existingUrl != null) {
|
||||
print('PlaceImageService: Image existante trouvée: $existingUrl');
|
||||
return existingUrl;
|
||||
}
|
||||
print('PlaceImageService: Aucune image existante trouvée pour: $location');
|
||||
return null;
|
||||
} catch (e) {
|
||||
print('PlaceImageService: Erreur lors de la recherche d\'image existante: $e');
|
||||
_errorService.logError('PlaceImageService', 'Erreur lors de la recherche d\'image existante: $e');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -35,14 +35,12 @@ class TripImageService {
|
||||
|
||||
/// Charge l'image pour un voyage spécifique
|
||||
Future<void> _loadImageForTrip(Trip trip) async {
|
||||
print('TripImageService: Recherche d\'image pour ${trip.title} (${trip.location})');
|
||||
|
||||
// D'abord vérifier si une image existe déjà dans le Storage
|
||||
String? imageUrl = await _placeImageService.getExistingImageUrl(trip.location);
|
||||
|
||||
// Si aucune image n'existe, en télécharger une nouvelle
|
||||
if (imageUrl == null) {
|
||||
print('TripImageService: Aucune image existante, téléchargement via Google Places...');
|
||||
imageUrl = await _placeImageService.getPlaceImageUrl(trip.location);
|
||||
}
|
||||
|
||||
@@ -54,9 +52,7 @@ class TripImageService {
|
||||
);
|
||||
|
||||
await _tripRepository.updateTrip(trip.id!, updatedTrip);
|
||||
print('TripImageService: Image mise à jour pour ${trip.title}: $imageUrl');
|
||||
} else {
|
||||
print('TripImageService: Aucune image trouvée pour ${trip.title}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,11 +132,8 @@ class TripImageService {
|
||||
/// Nettoie spécifiquement les doublons d'images
|
||||
Future<void> cleanupDuplicateImages() async {
|
||||
try {
|
||||
print('TripImageService: Début du nettoyage des doublons...');
|
||||
await _placeImageService.cleanupDuplicateImages();
|
||||
print('TripImageService: Nettoyage des doublons terminé');
|
||||
} catch (e) {
|
||||
print('TripImageService: Erreur lors du nettoyage des doublons: $e');
|
||||
_errorService.logError(
|
||||
'TripImageService',
|
||||
'Erreur lors du nettoyage des doublons: $e',
|
||||
|
||||
@@ -4,8 +4,6 @@ import '../lib/services/trip_image_service.dart';
|
||||
/// Script utilitaire pour nettoyer les images inutilisées
|
||||
/// À exécuter manuellement si nécessaire
|
||||
void main() async {
|
||||
print('🧹 Script de nettoyage des images inutilisées');
|
||||
print('=====================================');
|
||||
|
||||
try {
|
||||
final tripImageService = TripImageService();
|
||||
@@ -15,36 +13,21 @@ void main() async {
|
||||
const userId = 'YOUR_USER_ID_HERE';
|
||||
|
||||
if (userId == 'YOUR_USER_ID_HERE') {
|
||||
print('❌ Veuillez configurer votre userId dans le script');
|
||||
print(' Récupérez votre ID depuis Firebase Auth dans l\'app');
|
||||
return;
|
||||
}
|
||||
|
||||
print('📊 Récupération des statistiques...');
|
||||
final stats = await tripImageService.getImageStatistics(userId);
|
||||
|
||||
print('Statistiques actuelles:');
|
||||
print('- Voyages totaux: ${stats['totalTrips']}');
|
||||
print('- Voyages avec image: ${stats['tripsWithImages']}');
|
||||
print('- Voyages sans image: ${stats['tripsWithoutImages']}');
|
||||
|
||||
if (stats['tripsWithImages'] > 0) {
|
||||
print('\n🧹 Nettoyage des images inutilisées...');
|
||||
await tripImageService.cleanupUnusedImages(userId);
|
||||
|
||||
print('\n📊 Nouvelles statistiques...');
|
||||
final newStats = await tripImageService.getImageStatistics(userId);
|
||||
print('- Voyages totaux: ${newStats['totalTrips']}');
|
||||
print('- Voyages avec image: ${newStats['tripsWithImages']}');
|
||||
print('- Voyages sans image: ${newStats['tripsWithoutImages']}');
|
||||
} else {
|
||||
print('✅ Aucune image à nettoyer');
|
||||
}
|
||||
|
||||
print('\n✅ Script terminé avec succès');
|
||||
|
||||
} catch (e) {
|
||||
print('❌ Erreur lors du nettoyage: $e');
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ import '../lib/firebase_options.dart';
|
||||
|
||||
/// Script pour nettoyer les doublons d'images de Londres
|
||||
void main() async {
|
||||
print('🧹 Nettoyage spécifique des doublons d\'images de Londres');
|
||||
print('========================================================');
|
||||
|
||||
try {
|
||||
// Initialiser Firebase
|
||||
@@ -14,20 +12,13 @@ void main() async {
|
||||
options: DefaultFirebaseOptions.currentPlatform,
|
||||
);
|
||||
|
||||
print('✅ Firebase initialisé');
|
||||
|
||||
final tripImageService = TripImageService();
|
||||
|
||||
print('🔍 Analyse et nettoyage des doublons...');
|
||||
await tripImageService.cleanupDuplicateImages();
|
||||
|
||||
print('✅ Nettoyage terminé !');
|
||||
print('');
|
||||
print('🎯 Les doublons pour Londres (et autres destinations) ont été supprimés');
|
||||
print(' Seule l\'image la plus récente pour chaque destination a été conservée');
|
||||
|
||||
} catch (e) {
|
||||
print('❌ Erreur lors du nettoyage: $e');
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ import '../lib/firebase_options.dart';
|
||||
|
||||
/// Script de diagnostic pour analyser les images dans Firebase Storage
|
||||
void main() async {
|
||||
print('🔍 Diagnostic des images Firebase Storage');
|
||||
print('=========================================');
|
||||
|
||||
try {
|
||||
// Initialiser Firebase
|
||||
@@ -15,16 +13,12 @@ void main() async {
|
||||
|
||||
final storage = FirebaseStorage.instance;
|
||||
|
||||
print('📂 Analyse du dossier trip_images...');
|
||||
final listResult = await storage.ref('trip_images').listAll();
|
||||
|
||||
if (listResult.items.isEmpty) {
|
||||
print('❌ Aucune image trouvée dans trip_images/');
|
||||
return;
|
||||
}
|
||||
|
||||
print('📊 ${listResult.items.length} image(s) trouvée(s):');
|
||||
print('');
|
||||
|
||||
final Map<String, List<Map<String, dynamic>>> locationGroups = {};
|
||||
|
||||
@@ -32,7 +26,6 @@ void main() async {
|
||||
final item = listResult.items[i];
|
||||
final fileName = item.name;
|
||||
|
||||
print('${i + 1}. Fichier: $fileName');
|
||||
|
||||
try {
|
||||
// Récupérer les métadonnées
|
||||
@@ -44,14 +37,9 @@ void main() async {
|
||||
final source = customMeta['source'] ?? 'Inconnue';
|
||||
final uploadedAt = customMeta['uploadedAt'] ?? 'Inconnue';
|
||||
|
||||
print(' 📍 Location: $location');
|
||||
print(' 🏷️ Normalized: $normalizedLocation');
|
||||
print(' 📤 Source: $source');
|
||||
print(' 📅 Upload: $uploadedAt');
|
||||
|
||||
// Récupérer l'URL de téléchargement
|
||||
final downloadUrl = await item.getDownloadURL();
|
||||
print(' 🔗 URL: $downloadUrl');
|
||||
|
||||
// Grouper par location normalisée
|
||||
final groupKey = normalizedLocation != 'Non définie' ? normalizedLocation : location.toLowerCase();
|
||||
@@ -67,13 +55,11 @@ void main() async {
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
print(' ❌ Erreur lecture métadonnées: $e');
|
||||
|
||||
// Essayer de deviner la location depuis le nom du fichier
|
||||
final parts = fileName.split('_');
|
||||
if (parts.length >= 2) {
|
||||
final guessedLocation = parts.take(parts.length - 1).join('_');
|
||||
print(' 🤔 Location devinée: $guessedLocation');
|
||||
|
||||
if (!locationGroups.containsKey(guessedLocation)) {
|
||||
locationGroups[guessedLocation] = [];
|
||||
@@ -88,12 +74,9 @@ void main() async {
|
||||
}
|
||||
}
|
||||
|
||||
print('');
|
||||
}
|
||||
|
||||
// Analyser les doublons
|
||||
print('🔍 Analyse des doublons par location:');
|
||||
print('====================================');
|
||||
|
||||
int totalDuplicates = 0;
|
||||
for (final entry in locationGroups.entries) {
|
||||
@@ -101,31 +84,19 @@ void main() async {
|
||||
final images = entry.value;
|
||||
|
||||
if (images.length > 1) {
|
||||
print('⚠️ DOUBLONS détectés pour "$location": ${images.length} images');
|
||||
totalDuplicates += images.length - 1;
|
||||
|
||||
for (int i = 0; i < images.length; i++) {
|
||||
final image = images[i];
|
||||
print(' ${i + 1}. ${image['fileName']} (${image['uploadedAt']})');
|
||||
}
|
||||
print('');
|
||||
} else {
|
||||
print('✅ "$location": 1 image (OK)');
|
||||
}
|
||||
}
|
||||
|
||||
print('📈 Résumé:');
|
||||
print('- Total images: ${listResult.items.length}');
|
||||
print('- Locations uniques: ${locationGroups.length}');
|
||||
print('- Images en doublon: $totalDuplicates');
|
||||
print('- Économie possible: ${totalDuplicates} images peuvent être supprimées');
|
||||
|
||||
if (totalDuplicates > 0) {
|
||||
print('');
|
||||
print('💡 Suggestion: Utilisez la fonctionnalité de nettoyage pour supprimer les doublons');
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
print('❌ Erreur lors du diagnostic: $e');
|
||||
}
|
||||
}
|
||||
@@ -2,26 +2,21 @@ import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
|
||||
void main() async {
|
||||
print("🧹 Début du nettoyage des doublons Londres...");
|
||||
|
||||
try {
|
||||
await Firebase.initializeApp();
|
||||
print("✅ Firebase initialisé");
|
||||
|
||||
final storage = FirebaseStorage.instance;
|
||||
final ref = storage.ref().child('trip_images');
|
||||
|
||||
print("📋 Récupération de la liste des images...");
|
||||
final result = await ref.listAll();
|
||||
|
||||
print("📊 Nombre total d'images: ${result.items.length}");
|
||||
|
||||
// Grouper les images par ville
|
||||
Map<String, List<Reference>> imagesByCity = {};
|
||||
|
||||
for (var item in result.items) {
|
||||
final name = item.name;
|
||||
print("🖼️ Image trouvée: $name");
|
||||
|
||||
// Extraire la ville du nom de fichier
|
||||
String city = 'unknown';
|
||||
@@ -36,9 +31,7 @@ void main() async {
|
||||
imagesByCity[city]!.add(item);
|
||||
}
|
||||
|
||||
print("\n📍 Images par ville:");
|
||||
for (var entry in imagesByCity.entries) {
|
||||
print(" ${entry.key}: ${entry.value.length} image(s)");
|
||||
}
|
||||
|
||||
// Focus sur Londres/London
|
||||
@@ -46,10 +39,8 @@ void main() async {
|
||||
londonImages.addAll(imagesByCity['londres'] ?? []);
|
||||
londonImages.addAll(imagesByCity['london'] ?? []);
|
||||
|
||||
print("\n🏴 Images de Londres trouvées: ${londonImages.length}");
|
||||
|
||||
if (londonImages.length > 1) {
|
||||
print("🔄 Suppression des doublons...");
|
||||
|
||||
// Trier par timestamp (garder la plus récente)
|
||||
londonImages.sort((a, b) {
|
||||
@@ -58,27 +49,20 @@ void main() async {
|
||||
return timestampB.compareTo(timestampA); // Plus récent en premier
|
||||
});
|
||||
|
||||
print("📅 Images triées par timestamp:");
|
||||
for (var image in londonImages) {
|
||||
final timestamp = _extractTimestamp(image.name);
|
||||
print(" ${image.name} - $timestamp");
|
||||
}
|
||||
|
||||
// Supprimer toutes sauf la première (plus récente)
|
||||
for (int i = 1; i < londonImages.length; i++) {
|
||||
print("🗑️ Suppression: ${londonImages[i].name}");
|
||||
await londonImages[i].delete();
|
||||
}
|
||||
|
||||
print("✅ Suppression terminée. Image conservée: ${londonImages[0].name}");
|
||||
} else {
|
||||
print("ℹ️ Aucun doublon trouvé pour Londres");
|
||||
}
|
||||
|
||||
print("\n🎉 Nettoyage terminé !");
|
||||
|
||||
} catch (e) {
|
||||
print("❌ Erreur: $e");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +76,6 @@ int _extractTimestamp(String filename) {
|
||||
return int.parse(timestampPart);
|
||||
}
|
||||
} catch (e) {
|
||||
print("⚠️ Impossible d'extraire le timestamp de $filename");
|
||||
}
|
||||
return 0; // Timestamp par défaut
|
||||
}
|
||||
Reference in New Issue
Block a user