-
-
Notifications
You must be signed in to change notification settings - Fork 14
commit 7b4f24f
abduznik edited this page May 23, 2026
·
1 revision
Commit: 7b4f24fd24a5f59d7f56511060e8a787b73b8d8f
Author: Cool Contributor
Date: 2026-05-16
-
fix: single file foldered games download
-
part 2
Why: Fixes a bug or regression in the existing codebase.
lib/core/downloader/download_service.dart | 11 +++++++++--
lib/core/romm/romm_models.dart | 3 +++
2 files changed, 12 insertions(+), 2 deletions(-)
lib/core/downloader/download_service.dartlib/core/romm/romm_models.dart
diff --git a/lib/core/downloader/download_service.dart b/lib/core/downloader/download_service.dart
index eac2c85..e8b59a3 100644
--- a/lib/core/downloader/download_service.dart
+++ b/lib/core/downloader/download_service.dart
@@ -78,7 +78,14 @@ class DownloadService {
return;
}
- final finalPath = await directoryService.getRomFilePath(game);
+
+ bool isSingleFileFoldered = game.files.length == 1 && game.fsExtension == '';
+
+ String finalPath = await directoryService.getRomFilePath(game);
+ if (isSingleFileFoldered) {
+ final fileName = game.files[0]["file_name"];
+ finalPath = '$finalPath/$fileName';
+ }
final partPath = '$finalPath.part';
final partFile = File(partPath);
await partFile.parent.create(recursive: true);
@@ -225,7 +232,7 @@ class DownloadService {
final shouldExtract = game.isMultiFile ||
(isWindowsGame && isArchive) ||
((isZipSignature || isArchive) && !platformSupportsArchive);
-
+
if (shouldExtract) {
final extension = currentPath.split('.').last.toLowerCase();
yield DownloadProgress(
diff --git a/lib/core/romm/romm_models.dart b/lib/core/romm/romm_models.dart
index 72063c6..861b055 100644
--- a/lib/core/romm/romm_models.dart
+++ b/lib/core/romm/romm_models.dart
@@ -10,6 +10,7 @@ class Game {
final String? fileUrl; // Now nullable, to be replaced by constructed URL
final String? fileName; // Added: maps to 'file_name' in JSON
final String? fsName; // Added: maps to 'fs_name' in JSON
+ final String? fsExtension; // maps to 'fs_extension' in JSON
final int fileSize; // Kept
final String? multiFilePath; // maps to 'multi_file_path' in JSON
final bool hasMultipleFiles;
@@ -71,6 +72,7 @@ class Game {
this.fileUrl, // Now nullable
this.fileName, // Added
this.fsName, // Added
+ this.fsExtension,
required this.fileSize, // Kept
this.multiFilePath,
this.hasMultipleFiles = false,
@@ -109,6 +111,7 @@ class Game {
fileUrl: json['url_download']?.toString(), // Maps to original download URL, if present
fileName: json['file_name']?.toString(), // Mapped from JSON
fsName: json['fs_name']?.toString(), // Mapped from JSON
+ fsExtension: json['fs_extension']?.toString(),
fileSize: json['file_size_bytes'] is int ? json['file_size_bytes'] : 0,
multiFilePath: json['multi_file_path']?.toString(),
hasMultipleFiles: json['has_multiple_files'] as bool? ?? false,