Skip to content

Commit 8b865d4

Browse files
committed
Implement unimplemented error for getDefaultBlossomServerUrl and improve MIME type detection in ImageUtils
1 parent 278a182 commit 8b865d4

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

lib/config/providers/active_account_provider.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class DefaultWnUtils implements WnUtils {
5555

5656
@override
5757
Future<String> getDefaultBlossomServerUrl() {
58-
return getDefaultBlossomServerUrl();
58+
// TODO: Replace with the actual implementation (e.g., read from settings).
59+
throw UnimplementedError('getDefaultBlossomServerUrl not implemented');
5960
}
6061
}
6162

lib/utils/image_utils.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,21 @@ class ImageUtils {
99
static Future<String?> getMimeTypeFromPath(String filePath) async {
1010
try {
1111
final file = File(filePath);
12-
if (!file.existsSync()) {
13-
_logger.warning('File does not exist: $filePath, defaulting to image/jpeg');
12+
final fileExists = file.existsSync();
13+
if (!fileExists) {
14+
_logger.warning('File does not exist: $filePath');
1415
return null;
1516
}
16-
17-
final mimeType = lookupMimeType(filePath);
17+
List<int>? headerBytes;
18+
try {
19+
headerBytes = await file.openRead(0, 12).first;
20+
} catch (_) {
21+
// best-effort; fall back to extension-only detection
22+
}
23+
final mimeType = lookupMimeType(filePath, headerBytes: headerBytes);
1824
return mimeType;
19-
} catch (e) {
20-
_logger.severe('Error reading file for MIME type detection: $filePath, error: $e');
25+
} catch (e, st) {
26+
_logger.severe('Error reading file for MIME type detection: $filePath', e, st);
2127
return null;
2228
}
2329
}

0 commit comments

Comments
 (0)