Skip to content

Commit

Permalink
Fix torrents settings reset with native impl
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Ray committed Dec 10, 2024
1 parent e680210 commit ea5a784
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 20 deletions.
16 changes: 4 additions & 12 deletions app/lib/engine/transmission/transmission.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'dart:io';
import 'package:flutter_libtransmission/flutter_libtransmission.dart'
as flutter_libtransmission;
import 'package:path_provider/path_provider.dart';
import 'package:pikatorrent/engine/file.dart' as torrentFile;
import 'package:pikatorrent/engine/file.dart' as torrent_file;
import 'package:pikatorrent/engine/engine.dart';
import 'package:pikatorrent/engine/session.dart';
import 'package:pikatorrent/engine/torrent.dart';
Expand Down Expand Up @@ -133,6 +133,7 @@ class TransmissionEngine implements Engine {

@override
void dispose() {
print('dispose');
flutter_libtransmission.closeSession();
}

Expand Down Expand Up @@ -254,7 +255,7 @@ class TransmissionEngine implements Engine {
files: torrent.files
?.asMap()
.entries
.map((entry) => torrentFile.File(
.map((entry) => torrent_file.File(
name: entry.value.name,
length: entry.value.length,
bytesCompleted: entry.value.bytesCompleted,
Expand Down Expand Up @@ -288,15 +289,6 @@ class TransmissionEngine implements Engine {

@override
Future resetSettings() async {
// Close transmission session
dispose();
// Delete settings.json
final settingsFilePath =
path.join((await getConfigDir()).path, 'settings.json');
File settingsFile = File(settingsFilePath);
// Delete settings file
settingsFile.deleteSync();
// Re-init transmission
init();
flutter_libtransmission.resetSettings();
}
}
5 changes: 2 additions & 3 deletions app/lib/screens/settings/dialogs/reset_torrent_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ class ResetTorrentsSettingsDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text('Reset torrents settings'),
content: const Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[Text('All torrents settings will be reset. Torrents will be stopped and restarted.')],
children: <Widget>[Text('All torrents settings will be reset.')],
),
actions: <Widget>[
TextButton(
Expand All @@ -25,7 +24,7 @@ class ResetTorrentsSettingsDialog extends StatelessWidget {
},
),
TextButton(
child: const Text('OK'),
child: const Text('Reset'),
onPressed: () {
Navigator.of(context).pop();
handleOK();
Expand Down
2 changes: 0 additions & 2 deletions app/lib/screens/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
return Consumer2<AppModel, SessionModel>(
builder: (context, app, sessionModel, child) {
var downloadDir = sessionModel.session?.downloadDir ?? '';
var downloadQueueEnabled =
sessionModel.session?.downloadQueueEnabled ?? '';
var downloadQueueSize = sessionModel.session?.downloadQueueSize ?? '';

return ListView(children: [
Expand Down
4 changes: 2 additions & 2 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: c1968b54f937306e0218c95629da686720ffb76b
resolved-ref: c1968b54f937306e0218c95629da686720ffb76b
ref: "10fcbfc23cd8339e29dd12cc656457b9568ad86f"
resolved-ref: "10fcbfc23cd8339e29dd12cc656457b9568ad86f"
url: "https://github.com/G-Ray/flutter_libtransmission"
source: git
version: "0.0.1"
Expand Down
2 changes: 1 addition & 1 deletion app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies:
flutter_libtransmission:
git:
url: "https://github.com/G-Ray/flutter_libtransmission"
ref: c1968b54f937306e0218c95629da686720ffb76b
ref: 10fcbfc23cd8339e29dd12cc656457b9568ad86f

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand Down

0 comments on commit ea5a784

Please sign in to comment.