Compare commits

...

12 Commits

16 changed files with 291 additions and 162 deletions

View File

@ -12,6 +12,7 @@
### Changes from v2.0.4-rc
* Continue documentation updates
* Require `--name,-na` option for encryption provider
## v2.0.4-rc

View File

@ -36,10 +36,9 @@ template <typename drive> inline void help(std::vector<const char *> args) {
std::cout << " -di,--drive_information Display mounted drive "
"information"
<< std::endl;
std::cout
<< " -na,--name Unique name for S3 or Sia "
"instance [Required]"
<< std::endl;
std::cout << " -na,--name Unique configuration "
"name [Required for Encrypt, S3 and Sia]"
<< std::endl;
std::cout << " -s3,--s3 Enables S3 mode"
<< std::endl;
std::cout

View File

@ -105,7 +105,8 @@ auto main(int argc, char **argv) -> int {
}
}
}
} else if ((prov == provider_type::s3) || (prov == provider_type::sia)) {
} else if ((prov == provider_type::s3) || (prov == provider_type::sia) ||
(prov == provider_type::encrypt)) {
std::string data;
res = utils::cli::parse_string_option(
args, utils::cli::options::name_option, data);
@ -115,9 +116,9 @@ auto main(int argc, char **argv) -> int {
if (prov == provider_type::sia) {
unique_id = "default";
} else {
std::cerr << "Name of "
std::cerr << "Configuration name for '"
<< app_config::get_provider_display_name(prov)
<< " instance not provided" << std::endl;
<< "' was not provided" << std::endl;
res = exit_code::invalid_syntax;
}
}

View File

@ -171,12 +171,6 @@ void handlers::handle_get_mount_list(auto &&res) const {
auto data_dir = utils::file::directory{app_config::get_root_data_directory()};
nlohmann::json result;
auto encrypt_dir = data_dir.get_directory("encrypt");
if (encrypt_dir && encrypt_dir->get_file("config.json")) {
result["encrypt"].emplace_back("encrypt");
}
const auto process_dir = [&data_dir, &result](std::string_view name) {
auto name_dir = data_dir.get_directory(name);
if (not name_dir) {
@ -193,6 +187,7 @@ void handlers::handle_get_mount_list(auto &&res) const {
}
};
process_dir("encrypt");
process_dir("remote");
process_dir("s3");
process_dir("sia");
@ -223,14 +218,12 @@ void handlers::handle_get_mount_status(auto &&req, auto &&res) const {
auto status_name = app_config::get_provider_display_name(prov);
switch (prov) {
case provider_type::encrypt:
break;
case provider_type::remote: {
auto parts = utils::string::split(name, '_', false);
status_name = fmt::format("{}{}:{}", status_name, parts[0U], parts[1U]);
} break;
case provider_type::encrypt:
case provider_type::sia:
case provider_type::s3:
status_name = fmt::format("{}{}", status_name, name);
@ -305,7 +298,7 @@ auto handlers::launch_process(provider_type prov, std::string_view name,
std::string str_type;
switch (prov) {
case provider_type::encrypt:
str_type = "-en";
str_type = fmt::format("-en -na {}", name);
break;
case provider_type::remote: {

View File

@ -35,12 +35,16 @@ namespace {
std::unordered_map<repertory::provider_type,
std::unordered_map<std::string, std::string>>
map_of_maps{
{repertory::provider_type::encrypt, {}},
{repertory::provider_type::remote, {}},
{repertory::provider_type::s3, {}},
{repertory::provider_type::sia, {}},
{repertory::provider_type::encrypt, nlohmann::json::object()},
{repertory::provider_type::remote, nlohmann::json::object()},
{repertory::provider_type::s3, nlohmann::json::object()},
{repertory::provider_type::sia, nlohmann::json::object()},
};
if (json.is_null() || json.empty()) {
return map_of_maps;
}
for (const auto &[prov, map] : map_of_maps) {
for (const auto &[key, value] :
json[repertory::provider_type_to_string(prov)].items()) {
@ -56,7 +60,7 @@ namespace {
}
[[nodiscard]] auto to_json(const auto &map_of_maps) -> nlohmann::json {
nlohmann::json json;
auto json = nlohmann::json::object();
for (const auto &[prov, map] : map_of_maps) {
for (const auto &[key, value] : map) {
json[repertory::provider_type_to_string(prov)][key] = value;
@ -75,9 +79,18 @@ mgmt_app_config::mgmt_app_config() {
utils::path::combine(app_config::get_root_data_directory(), {"ui.json"});
try {
if (not utils::file::directory{app_config::get_root_data_directory()}
.create_directory()) {
throw utils::error::create_exception(
function_name, {
"failed to create directory",
app_config::get_root_data_directory(),
});
}
nlohmann::json data;
if (utils::file::read_json_file(config_file, data)) {
api_auth_ = data.at(JSON_API_AUTH).get<std::string>();
api_auth_ = data.at(JSON_API_PASSWORD).get<std::string>();
api_port_ = data.at(JSON_API_PORT).get<std::uint16_t>();
api_user_ = data.at(JSON_API_USER).get<std::string>();
locations_ = from_json(data.at(JSON_MOUNT_LOCATIONS));
@ -87,6 +100,7 @@ mgmt_app_config::mgmt_app_config() {
utils::error::raise_error(
function_name, utils::get_last_error_code(),
fmt::format("failed to read file|{}", config_file));
save();
} catch (const std::exception &ex) {
utils::error::raise_error(
function_name, ex, fmt::format("failed to read file|{}", config_file));
@ -121,7 +135,7 @@ void mgmt_app_config::save() const {
}
nlohmann::json data;
data[JSON_API_AUTH] = api_auth_;
data[JSON_API_PASSWORD] = api_auth_;
data[JSON_API_PORT] = api_port_;
data[JSON_API_USER] = api_user_;
data[JSON_MOUNT_LOCATIONS] = to_json(locations_);

View File

@ -1,4 +1,6 @@
autofocus
cupertino
cupertinoicons
fromargb
onetwothree
onetwothree
rocksdb

View File

@ -1 +1 @@
const String appTitle = "Repertory Management Portal";
const String appTitle = 'Repertory Management Portal';

View File

@ -1,15 +1,15 @@
import 'package:flutter/foundation.dart';
String formatMountName(String type, String name) {
if (type == "remote") {
return name.replaceAll("_", ":");
if (type == 'remote') {
return name.replaceAll('_', ':');
}
return name;
}
String getBaseUri() {
if (kDebugMode) {
return "http://127.0.0.1:30000";
return 'http://127.0.0.1:30000';
}
return Uri.base.origin;
}

View File

@ -1,11 +1,9 @@
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:repertory/constants.dart' as constants;
import 'package:repertory/helpers.dart';
import 'package:repertory/models/mount.dart';
import 'package:repertory/models/mount_list.dart';
import 'package:repertory/types/mount_config.dart';
import 'package:repertory/widgets/add_mount_widget.dart';
import 'package:repertory/widgets/mount_list_widget.dart';
import 'package:repertory/widgets/mount_settings.dart';
@ -20,7 +18,7 @@ class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
Widget build(context) {
return MaterialApp(
title: constants.appTitle,
theme: ThemeData(
@ -78,11 +76,64 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
bool _allowAdd = true;
String _mountType = "S3";
String? _apiPassword;
String? _apiPort;
String? _bucket;
String? _encryptionToken;
String? _hostNameOrIp;
String _mountType = 'Encrypt';
String _mountName = "";
String? _path;
void _resetData() {
_apiPassword = null;
_apiPort = null;
_bucket = null;
_encryptionToken = null;
_hostNameOrIp = null;
_mountName = "";
_mountType = 'Encrypt';
_path = null;
}
void _updateData(String name, String? value) {
switch (name) {
case 'ApiPassword':
_apiPassword = value ?? '';
return;
case 'ApiPort':
_apiPort = value ?? '';
return;
case 'Bucket':
_bucket = value ?? '';
return;
case 'EncryptionToken':
_encryptionToken = value ?? '';
return;
case 'HostNameOrIp':
_hostNameOrIp = value ?? '';
return;
case 'Name':
_mountName = value ?? '';
return;
case 'Provider':
_mountType = value ?? 'Encrypt';
return;
case 'Path':
_path = value ?? '';
return;
}
}
@override
Widget build(BuildContext context) {
Widget build(context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
@ -96,25 +147,14 @@ class _MyHomePageState extends State<MyHomePage> {
? () {
showDialog(
context: context,
builder: (BuildContext context) {
builder: (context) {
return AlertDialog(
title: const Text('Add Mount'),
content: Consumer<MountList>(
builder: (_, mountList, __) {
builder: (_, MountList mountList, __) {
return AddMountWidget(
allowEncrypt:
mountList.items.firstWhereOrNull(
(MountConfig item) =>
item.type.toLowerCase() == "encrypt",
) ==
null,
mountType: _mountType,
onNameChanged: (mountName) {
_mountName = mountName ?? "";
},
onTypeChanged: (mountType) {
_mountType = mountType ?? "S3";
},
onDataChanged: _updateData,
);
},
),
@ -122,8 +162,7 @@ class _MyHomePageState extends State<MyHomePage> {
TextButton(
child: const Text('Cancel'),
onPressed: () {
_mountType = "S3";
_mountName = "";
_resetData();
Navigator.of(context).pop();
},
),
@ -133,10 +172,18 @@ class _MyHomePageState extends State<MyHomePage> {
setState(() => _allowAdd = false);
Provider.of<MountList>(context, listen: false)
.add(_mountType, _mountName)
.add(
_mountType,
_mountName,
apiPassword: _apiPassword,
apiPort: _apiPort,
bucket: _bucket,
encryptionToken: _encryptionToken,
hostNameOrIp: _hostNameOrIp,
path: _path,
)
.then((_) {
_mountType = "S3";
_mountName = "";
_resetData();
setState(() {
_allowAdd = true;
});
@ -159,4 +206,13 @@ class _MyHomePageState extends State<MyHomePage> {
),
);
}
@override
void setState(VoidCallback fn) {
if (!mounted) {
return;
}
super.setState(fn);
}
}

View File

@ -79,6 +79,18 @@ class Mount with ChangeNotifier {
}
Future<String?> getMountLocation() async {
return "~/mnt/encrypt";
final response = await http.get(
Uri.parse(
Uri.encodeFull(
'${getBaseUri()}/api/v1/get_mount_location?name=$name&type=$type',
),
),
);
if (response.statusCode != 200) {
return null;
}
return jsonDecode(response.body)['Location'] as String;
}
}

View File

@ -48,11 +48,22 @@ class MountList with ChangeNotifier {
});
}
Future<void> add(String type, String name) async {
Future<void> add(
String type,
String name, {
String? apiPassword,
String? apiPort,
String? bucket,
String? encryptionToken,
String? hostNameOrIp,
String? path,
}) async {
await http.post(
Uri.parse(
Uri.encodeFull(
'${getBaseUri()}/api/v1/add_mount?name=$name&type=$type',
'${getBaseUri()}/api/v1/add_mount?name=$name&type=$type&bucket=$bucket'
'&path=$path&apiPassword=$apiPassword&apiPort=$apiPort&hostNameOrIp=$hostNameOrIp'
'&encryptionToken=$encryptionToken',
),
),
);

View File

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
class MountConfig {
final String _name;
String _path = "";
String _path = '';
Map<String, dynamic> _settings = {};
IconData _state = Icons.toggle_off;
final String _type;
@ -25,7 +25,7 @@ class MountConfig {
}
void updateStatus(Map<String, dynamic> status) {
_path = status["Location"] as String;
_state = status["Active"] as bool ? Icons.toggle_on : Icons.toggle_off;
_path = status['Location'] as String;
_state = status['Active'] as bool ? Icons.toggle_on : Icons.toggle_off;
}
}

View File

@ -1,30 +1,23 @@
import 'package:flutter/material.dart';
class AddMountWidget extends StatefulWidget {
final bool allowEncrypt;
final String mountType;
final void Function(String? newName) onNameChanged;
final void Function(String? newType) onTypeChanged;
final void Function(String name, String? value) onDataChanged;
final _items = <String>["S3", "Sia"];
AddMountWidget({
const AddMountWidget({
super.key,
required this.allowEncrypt,
required this.mountType,
required this.onNameChanged,
required this.onTypeChanged,
}) {
if (allowEncrypt) {
_items.insert(0, "Encrypt");
}
}
required this.onDataChanged,
});
@override
State<AddMountWidget> createState() => _AddMountWidgetState();
}
class _AddMountWidgetState extends State<AddMountWidget> {
static const _items = <String>['Encrypt', 'Remote', 'S3', 'Sia'];
static const _padding = 15.0;
String? _mountType;
@override
@ -33,8 +26,33 @@ class _AddMountWidgetState extends State<AddMountWidget> {
super.initState();
}
List<Widget> _createTextField(
String title,
String dataName, {
String? value,
}) {
return [
const SizedBox(height: _padding),
Text(
title,
textAlign: TextAlign.left,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
TextField(
decoration: InputDecoration(),
onChanged: (value) => widget.onDataChanged(dataName, value),
controller: TextEditingController(text: value),
),
];
}
@override
Widget build(BuildContext context) {
final mountTypeLower = _mountType?.toLowerCase();
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
@ -52,17 +70,17 @@ class _AddMountWidgetState extends State<AddMountWidget> {
fontWeight: FontWeight.bold,
),
),
const SizedBox(width: 10),
const SizedBox(width: _padding),
DropdownButton<String>(
value: _mountType,
onChanged: (value) {
setState(() {
_mountType = value;
});
widget.onTypeChanged(value);
widget.onDataChanged('Provider', value);
},
items:
widget._items.map<DropdownMenuItem<String>>((item) {
_items.map<DropdownMenuItem<String>>((item) {
return DropdownMenuItem<String>(
value: item,
child: Text(item),
@ -71,22 +89,31 @@ class _AddMountWidgetState extends State<AddMountWidget> {
),
],
),
const SizedBox(height: 10),
if (_mountType?.toLowerCase() != 'encrypt')
Text(
'Configuration Name',
textAlign: TextAlign.left,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
if (mountTypeLower != 'remote')
..._createTextField('Configuration Name', 'Name'),
if (mountTypeLower == 'encrypt') ..._createTextField('Path', 'Path'),
if (mountTypeLower == 'sia')
..._createTextField('ApiPassword', 'ApiPassword'),
if (mountTypeLower == 's3' || mountTypeLower == 'sia')
..._createTextField(
'Bucket',
'Bucket',
value: mountTypeLower == 'sia' ? 'default' : null,
),
if (_mountType?.toLowerCase() != 'encrypt')
TextField(
autofocus: true,
decoration: InputDecoration(),
onChanged: widget.onNameChanged,
if (mountTypeLower == 'remote' || mountTypeLower == 'sia')
..._createTextField(
'HostNameOrIp',
'HostNameOrIp',
value: 'localhost',
),
if (mountTypeLower == 'remote' || mountTypeLower == 'sia')
..._createTextField(
'ApiPort',
'ApiPort',
value: mountTypeLower == 'sia' ? '9980' : null,
),
if (mountTypeLower == 'remote')
..._createTextField('EncryptionToken', 'EncryptionToken'),
],
);
}

View File

@ -4,14 +4,9 @@ import 'package:repertory/models/mount.dart';
import 'package:repertory/models/mount_list.dart';
import 'package:repertory/widgets/mount_widget.dart';
class MountListWidget extends StatefulWidget {
class MountListWidget extends StatelessWidget {
const MountListWidget({super.key});
@override
State<MountListWidget> createState() => _MountListWidgetState();
}
class _MountListWidgetState extends State<MountListWidget> {
@override
Widget build(BuildContext context) {
return Consumer<MountList>(

View File

@ -200,70 +200,70 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
List<SettingsTile> siaConfigSettings = [];
_settings.forEach((key, value) {
if (key == "ApiAuth") {
if (key == 'ApiAuth') {
_addPasswordSetting(commonSettings, _settings, key, value);
} else if (key == "ApiPort") {
} else if (key == 'ApiPort') {
_addIntSetting(commonSettings, _settings, key, value);
} else if (key == "ApiUser") {
} else if (key == 'ApiUser') {
_addStringSetting(commonSettings, _settings, key, value, Icons.person);
} else if (key == "DatabaseType") {
} else if (key == 'DatabaseType') {
_addListSetting(commonSettings, _settings, key, value, [
"rocksdb",
"sqlite",
'rocksdb',
'sqlite',
], Icons.dataset);
} else if (key == "DownloadTimeoutSeconds") {
} else if (key == 'DownloadTimeoutSeconds') {
_addIntSetting(commonSettings, _settings, key, value);
} else if (key == "EnableDownloadTimeout") {
} else if (key == 'EnableDownloadTimeout') {
_addBooleanSetting(commonSettings, _settings, key, value);
} else if (key == "EnableDriveEvents") {
} else if (key == 'EnableDriveEvents') {
_addBooleanSetting(commonSettings, _settings, key, value);
} else if (key == "EventLevel") {
} else if (key == 'EventLevel') {
_addListSetting(commonSettings, _settings, key, value, [
"critical",
"error",
"warn",
"info",
"debug",
"trace",
'critical',
'error',
'warn',
'info',
'debug',
'trace',
], Icons.event);
} else if (key == "EvictionDelayMinutes") {
} else if (key == 'EvictionDelayMinutes') {
_addIntSetting(commonSettings, _settings, key, value);
} else if (key == "EvictionUseAccessedTime") {
} else if (key == 'EvictionUseAccessedTime') {
_addBooleanSetting(commonSettings, _settings, key, value);
} else if (key == "MaxCacheSizeBytes") {
} else if (key == 'MaxCacheSizeBytes') {
_addIntSetting(commonSettings, _settings, key, value);
} else if (key == "MaxUploadCount") {
} else if (key == 'MaxUploadCount') {
_addIntSetting(commonSettings, _settings, key, value);
} else if (key == "OnlineCheckRetrySeconds") {
} else if (key == 'OnlineCheckRetrySeconds') {
_addIntSetting(commonSettings, _settings, key, value);
} else if (key == "PreferredDownloadType") {
} else if (key == 'PreferredDownloadType') {
_addListSetting(commonSettings, _settings, key, value, [
"default",
"direct",
"ring_buffer",
'default',
'direct',
'ring_buffer',
], Icons.download);
} else if (key == "RetryReadCount") {
} else if (key == 'RetryReadCount') {
_addIntSetting(commonSettings, _settings, key, value);
} else if (key == "RingBufferFileSize") {
} else if (key == 'RingBufferFileSize') {
_addIntListSetting(
commonSettings,
_settings,
key,
value,
["128", "256", "512", "1024", "2048"],
['128', '256', '512', '1024', '2048'],
512,
Icons.animation,
);
} else if (key == "EncryptConfig") {
} else if (key == 'EncryptConfig') {
value.forEach((subKey, subValue) {
if (subKey == "EncryptionToken") {
if (subKey == 'EncryptionToken') {
_addPasswordSetting(
encryptConfigSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "Path") {
} else if (subKey == 'Path') {
_addStringSetting(
encryptConfigSettings,
_settings[key],
@ -273,9 +273,9 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
);
}
});
} else if (key == "HostConfig") {
} else if (key == 'HostConfig') {
value.forEach((subKey, subValue) {
if (subKey == "AgentString") {
if (subKey == 'AgentString') {
_addStringSetting(
hostConfigSettings,
_settings[key],
@ -283,21 +283,21 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
subValue,
Icons.support_agent,
);
} else if (subKey == "ApiPassword") {
} else if (subKey == 'ApiPassword') {
_addPasswordSetting(
hostConfigSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "ApiPort") {
} else if (subKey == 'ApiPort') {
_addIntSetting(
hostConfigSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "ApiUser") {
} else if (subKey == 'ApiUser') {
_addStringSetting(
hostConfigSettings,
_settings[key],
@ -305,7 +305,7 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
subValue,
Icons.person,
);
} else if (subKey == "HostNameOrIp") {
} else if (subKey == 'HostNameOrIp') {
_addStringSetting(
hostConfigSettings,
_settings[key],
@ -313,7 +313,7 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
subValue,
Icons.computer,
);
} else if (subKey == "Path") {
} else if (subKey == 'Path') {
_addStringSetting(
hostConfigSettings,
_settings[key],
@ -321,16 +321,16 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
subValue,
Icons.route,
);
} else if (subKey == "Protocol") {
} else if (subKey == 'Protocol') {
_addListSetting(
hostConfigSettings,
_settings[key],
subKey,
subValue,
["http", "https"],
['http', 'https'],
Icons.http,
);
} else if (subKey == "TimeoutMs") {
} else if (subKey == 'TimeoutMs') {
_addIntSetting(
hostConfigSettings,
_settings[key],
@ -339,23 +339,23 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
);
}
});
} else if (key == "RemoteConfig") {
} else if (key == 'RemoteConfig') {
value.forEach((subKey, subValue) {
if (subKey == "ApiPort") {
if (subKey == 'ApiPort') {
_addIntSetting(
remoteConfigSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "EncryptionToken") {
} else if (subKey == 'EncryptionToken') {
_addPasswordSetting(
remoteConfigSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "HostNameOrIp") {
} else if (subKey == 'HostNameOrIp') {
_addStringSetting(
remoteConfigSettings,
_settings[key],
@ -363,21 +363,21 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
subValue,
Icons.computer,
);
} else if (subKey == "MaxConnections") {
} else if (subKey == 'MaxConnections') {
_addIntSetting(
remoteConfigSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "ReceiveTimeoutMs") {
} else if (subKey == 'ReceiveTimeoutMs') {
_addIntSetting(
remoteConfigSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "SendTimeoutMs") {
} else if (subKey == 'SendTimeoutMs') {
_addIntSetting(
remoteConfigSettings,
_settings[key],
@ -386,27 +386,27 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
);
}
});
} else if (key == "RemoteMount") {
} else if (key == 'RemoteMount') {
value.forEach((subKey, subValue) {
if (subKey == "Enable") {
if (subKey == 'Enable') {
List<SettingsTile> tempSettings = [];
_addBooleanSetting(tempSettings, _settings[key], subKey, subValue);
remoteMountSettings.insertAll(0, tempSettings);
} else if (subKey == "ApiPort") {
} else if (subKey == 'ApiPort') {
_addIntSetting(
remoteMountSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "ClientPoolSize") {
} else if (subKey == 'ClientPoolSize') {
_addIntSetting(
remoteMountSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "EncryptionToken") {
} else if (subKey == 'EncryptionToken') {
_addPasswordSetting(
remoteMountSettings,
_settings[key],
@ -415,16 +415,16 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
);
}
});
} else if (key == "S3Config") {
} else if (key == 'S3Config') {
value.forEach((subKey, subValue) {
if (subKey == "AccessKey") {
if (subKey == 'AccessKey') {
_addPasswordSetting(
s3ConfigSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "Bucket") {
} else if (subKey == 'Bucket') {
_addStringSetting(
s3ConfigSettings,
_settings[key],
@ -432,14 +432,14 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
subValue,
Icons.folder,
);
} else if (subKey == "EncryptionToken") {
} else if (subKey == 'EncryptionToken') {
_addPasswordSetting(
s3ConfigSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "Region") {
} else if (subKey == 'Region') {
_addStringSetting(
s3ConfigSettings,
_settings[key],
@ -447,16 +447,16 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
subValue,
Icons.map,
);
} else if (subKey == "SecretKey") {
} else if (subKey == 'SecretKey') {
_addPasswordSetting(
s3ConfigSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "TimeoutMs") {
} else if (subKey == 'TimeoutMs') {
_addIntSetting(s3ConfigSettings, _settings[key], subKey, subValue);
} else if (subKey == "URL") {
} else if (subKey == 'URL') {
_addStringSetting(
s3ConfigSettings,
_settings[key],
@ -464,14 +464,14 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
subValue,
Icons.http,
);
} else if (subKey == "UsePathStyle") {
} else if (subKey == 'UsePathStyle') {
_addBooleanSetting(
s3ConfigSettings,
_settings[key],
subKey,
subValue,
);
} else if (subKey == "UseRegionInURL") {
} else if (subKey == 'UseRegionInURL') {
_addBooleanSetting(
s3ConfigSettings,
_settings[key],
@ -480,9 +480,9 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
);
}
});
} else if (key == "SiaConfig") {
} else if (key == 'SiaConfig') {
value.forEach((subKey, subValue) {
if (subKey == "Bucket") {
if (subKey == 'Bucket') {
_addStringSetting(
siaConfigSettings,
_settings[key],
@ -527,7 +527,7 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
SettingsSection(
title: const Text('Remote Mount'),
tiles:
_settings["RemoteMount"]["Enable"] as bool
_settings['RemoteMount']['Enable'] as bool
? remoteMountSettings
: [remoteMountSettings[0]],
),
@ -565,4 +565,13 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
_settings = jsonDecode(jsonEncode(widget.mount.mountConfig.settings));
super.initState();
}
@override
void setState(VoidCallback fn) {
if (!mounted) {
return;
}
super.setState(fn);
}
}

View File

@ -109,4 +109,13 @@ class _MountWidgetState extends State<MountWidget> {
Provider.of<Mount>(context, listen: false).refresh();
});
}
@override
void setState(VoidCallback fn) {
if (!mounted) {
return;
}
super.setState(fn);
}
}