修改id生成机制
This commit is contained in:
@@ -22,7 +22,7 @@ class AlbumRepository {
|
||||
.map((dir) {
|
||||
final name = p.basename(dir.path);
|
||||
return Album(
|
||||
id: name.hashCode,
|
||||
id: dir.path.hashCode,
|
||||
name: name,
|
||||
createdAt: dir.statSync().changed,
|
||||
updatedAt: dir.statSync().changed,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -17,7 +17,7 @@ class Vips {
|
||||
/// 如果同时指定 [w] 和 [h],图片将按比例缩放以适应指定尺寸
|
||||
Future<File> generatePreview(String imgPath, {int? w, int? h}) async {
|
||||
// 生成缓存文件名:包含原图 hash 和尺寸信息
|
||||
final baseName = basename(imgPath).hashCode.toString();
|
||||
final baseName = imgPath.hashCode.toString();
|
||||
final sizeSuffix = _buildSizeSuffix(w, h);
|
||||
final imgOut = "$cacheDir/preview/$baseName$sizeSuffix.webp";
|
||||
final outFile = File(imgOut);
|
||||
|
||||
Reference in New Issue
Block a user