修改id生成机制

This commit is contained in:
2026-04-04 14:24:18 +08:00
parent ff1227cde6
commit baefafeff7
3 changed files with 7 additions and 7 deletions

View File

@@ -22,7 +22,7 @@ class PhotoRepository {
await dir
.list()
.where((f) => f is Directory)
.where((d) => p.basename(d.path).hashCode == id)
.where((d) => d.path.hashCode == id)
.first
as Directory;
} on StateError {
@@ -45,7 +45,7 @@ class PhotoRepository {
final dimensions = _getImageDimensions(file, mimeType);
return Photo(
id: fileName.hashCode,
id: file.path.hashCode,
albumId: id,
filePath: file.path,
fileName: fileName,
@@ -73,7 +73,7 @@ class PhotoRepository {
.list(recursive: true)
.where((f) => f is File)
.map((f) => f as File)
.firstWhere((f) => p.basename(f.path).hashCode == id);
.firstWhere((f) => f.path.hashCode == id);
} on StateError {
// firstWhere throws StateError when no element is found
return null;
@@ -84,8 +84,8 @@ class PhotoRepository {
final dimensions = _getImageDimensions(file, mimeType);
return Photo(
id: p.basename(file.path).hashCode,
albumId: p.basename(file.parent.path).hashCode,
id: file.path.hashCode,
albumId: file.parent.path.hashCode,
filePath: file.path,
fileName: p.basename(file.path),
fileSize: stat.size,