fix: use correct portable settings file when started via autostart (#1562)

This commit is contained in:
Tien Do Nam
2024-07-25 12:45:58 +02:00
committed by GitHub
parent ba7c6d2c4c
commit e9595abd19
2 changed files with 12 additions and 1 deletions
+1
View File
@@ -4,6 +4,7 @@
- feat(windows): use bigger icon for the installer (@Tienisto)
- fix: memory leak when receiving files, properly receive files that exceed available RAM (@Tienisto)
- fix(android): save files outside of Download folder (@Tienisto)
- fix(windows): use correct portable settings file when started via autostart (@Tienisto)
- fix(windows): make installer work on arm64 (@Tienisto)
## 1.15.1 (2024-07-18)
@@ -1,8 +1,18 @@
import 'dart:io';
import 'package:localsend_app/util/shared_preferences/shared_preferences_file.dart';
import 'package:path/path.dart' as path;
/// Custom implementation of SharedPreferencesStorePlatform
/// that uses a file named settings.json located next to the executable.
/// This is used to for portable mode.
class SharedPreferencesPortable extends SharedPreferencesFile {
SharedPreferencesPortable() : super(filePath: 'settings.json', beautify: true);
SharedPreferencesPortable() : super(filePath: _getSettingsPathFromExecutable(), beautify: true);
}
/// Returns the absolute path to the settings.json file next to the executable.
String _getSettingsPathFromExecutable() {
final executablePath = Platform.resolvedExecutable;
final executableParentPath = File(executablePath).parent.path;
return path.join(executableParentPath, 'settings.json');
}