Skip to content
This repository was archived by the owner on Apr 3, 2025. It is now read-only.

Commit c9bd02b

Browse files
committed
feat(radarr): support moving files when editing the storage path
1 parent cfbfb2b commit c9bd02b

File tree

9 files changed

+73
-18
lines changed

9 files changed

+73
-18
lines changed

assets/localization/en.json

+5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"lunasea.Months": "{} Months",
7979
"lunasea.MonthsAgo": "{} Months Ago",
8080
"lunasea.New": "New",
81+
"lunasea.No": "No",
8182
"lunasea.NotSet": "Not Set",
8283
"lunasea.NoModulesEnabled": "No Modules Enabled",
8384
"lunasea.OneDay": "1 Day",
@@ -127,6 +128,7 @@
127128
"lunasea.Website": "Website",
128129
"lunasea.Years": "{} Years",
129130
"lunasea.YearsAgo": "{} Years Ago",
131+
"lunasea.Yes": "Yes",
130132
"overseerr.Audio": "Audio",
131133
"overseerr.Approved": "Approved",
132134
"overseerr.Available": "Available",
@@ -172,6 +174,7 @@
172174
"radarr.Codec": "Codec",
173175
"radarr.Configure": "Configure",
174176
"radarr.Copy": "Copy",
177+
"radarr.CopyFiles": "Hardlink/Copy Files",
175178
"radarr.CopyFull": "Hardlink/Copy Files",
176179
"radarr.CutoffUnmet": "Cutoff Unmet",
177180
"radarr.DateAdded": "Date Added",
@@ -208,6 +211,8 @@
208211
"radarr.MonitorMovie": "Monitor Movie",
209212
"radarr.More": "More",
210213
"radarr.Move": "Move",
214+
"radarr.MoveFiles": "Move Files",
215+
"radarr.MoveFilesDescription": "Would you like to move the files?",
211216
"radarr.MoveFull": "Move Files",
212217
"radarr.Movie": "Movie",
213218
"radarr.Movies": "Movies",

lib/api/radarr/commands/movie.dart

+9-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ class RadarrCommandHandlerMovie {
2929
///
3030
/// Required Parameters:
3131
/// - `movie`: [RadarrMovie] object with the updated information
32-
Future<RadarrMovie> update({required RadarrMovie movie}) async =>
33-
_commandUpdateMovie(_client, movie: movie);
32+
Future<RadarrMovie> update({
33+
required RadarrMovie movie,
34+
bool moveFiles = false,
35+
}) async =>
36+
_commandUpdateMovie(
37+
_client,
38+
movie: movie,
39+
moveFiles: moveFiles,
40+
);
3441

3542
/// Handler for [movie/{id}](https://radarr.video/docs/api/#/Movie/deleteMovie).
3643
///

lib/api/radarr/commands/movie/update_movie.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ part of radarr_commands;
33
Future<RadarrMovie> _commandUpdateMovie(
44
Dio client, {
55
required RadarrMovie movie,
6+
required bool moveFiles,
67
}) async {
7-
Response response = await client.put('movie', data: movie.toJson());
8+
Response response = await client.put(
9+
'movie',
10+
data: movie.toJson(),
11+
queryParameters: {
12+
'moveFiles': moveFiles,
13+
},
14+
);
815
return RadarrMovie.fromJson(response.data);
916
}

lib/modules/radarr/core/api_helper.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,15 @@ class RadarrAPIHelper {
260260
Future<bool> updateMovie({
261261
required BuildContext context,
262262
required RadarrMovie movie,
263+
required bool moveFiles,
263264
bool showSnackbar = true,
264265
}) async {
265266
if (context.read<RadarrState>().enabled) {
266267
return await context
267268
.read<RadarrState>()
268269
.api!
269270
.movie
270-
.update(movie: movie)
271+
.update(movie: movie, moveFiles: moveFiles)
271272
.then((_) async {
272273
return await context
273274
.read<RadarrState>()

lib/modules/radarr/core/dialogs.dart

+27
Original file line numberDiff line numberDiff line change
@@ -702,4 +702,31 @@ class RadarrDialogs {
702702
contentPadding: LunaDialog.listDialogContentPadding(),
703703
);
704704
}
705+
706+
Future<bool> moveFiles() async {
707+
bool _flag = false;
708+
709+
void _setValues(bool flag) {
710+
_flag = flag;
711+
Navigator.of(LunaState.context, rootNavigator: true).pop();
712+
}
713+
714+
await LunaDialog.dialog(
715+
context: LunaState.context,
716+
title: 'radarr.MoveFiles'.tr(),
717+
contentPadding: LunaDialog.textDialogContentPadding(),
718+
cancelButtonText: 'lunasea.No'.tr(),
719+
buttons: [
720+
LunaDialog.button(
721+
text: 'lunasea.Yes'.tr(),
722+
onPressed: () => _setValues(true),
723+
),
724+
],
725+
content: [
726+
LunaDialog.textContent(text: 'radarr.MoveFilesDescription'.tr()),
727+
],
728+
);
729+
730+
return _flag;
731+
}
705732
}

lib/modules/radarr/routes/edit_movie/widgets/bottom_action_bar.dart

+15-12
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,22 @@ class RadarrEditMovieActionBar extends StatelessWidget {
2424
}
2525

2626
Future<void> _updateOnTap(BuildContext context) async {
27-
if (context.read<RadarrMoviesEditState>().canExecuteAction) {
28-
context.read<RadarrMoviesEditState>().state = LunaLoadingState.ACTIVE;
29-
if (context.read<RadarrMoviesEditState>().movie != null) {
30-
RadarrMovie movie = context
31-
.read<RadarrMoviesEditState>()
32-
.movie!
33-
.updateEdits(context.read<RadarrMoviesEditState>());
34-
bool result = await RadarrAPIHelper().updateMovie(
35-
context: context,
36-
movie: movie,
37-
);
38-
if (result) LunaRouter().popSafely();
27+
final state = context.read<RadarrMoviesEditState>();
28+
state.state = LunaLoadingState.ACTIVE;
29+
30+
if (state.canExecuteAction && state.movie != null) {
31+
bool moveFiles = false;
32+
if (state.path != state.movie?.path) {
33+
moveFiles = await RadarrDialogs().moveFiles();
3934
}
35+
36+
final movie = state.movie!.updateEdits(state);
37+
bool result = await RadarrAPIHelper().updateMovie(
38+
context: context,
39+
movie: movie,
40+
moveFiles: moveFiles,
41+
);
42+
if (result) LunaRouter().popSafely();
4043
}
4144
}
4245
}

lib/modules/settings/routes/system/route.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class _State extends State<SystemRoute> with LunaScrollControllerMixin {
6666
Widget _clearImageCache() {
6767
return LunaBlock(
6868
title: 'Clear Image Cache',
69-
body: const [TextSpan(text: 'Clear cached images from the disk')],
69+
body: const [TextSpan(text: 'Clear Cached Images From the Disk')],
7070
trailing: const LunaIconButton(icon: Icons.image_not_supported_rounded),
7171
onTap: () async {
7272
bool result = await SettingsDialogs().clearImageCache(context);

localization/lunasea/en.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"lunasea.Months": "{} Months",
5858
"lunasea.MonthsAgo": "{} Months Ago",
5959
"lunasea.New": "New",
60+
"lunasea.No": "No",
6061
"lunasea.NotSet": "Not Set",
6162
"lunasea.NoModulesEnabled": "No Modules Enabled",
6263
"lunasea.OneDay": "1 Day",
@@ -105,5 +106,6 @@
105106
"lunasea.Warning": "Warning",
106107
"lunasea.Website": "Website",
107108
"lunasea.Years": "{} Years",
108-
"lunasea.YearsAgo": "{} Years Ago"
109+
"lunasea.YearsAgo": "{} Years Ago",
110+
"lunasea.Yes": "Yes"
109111
}

localization/radarr/en.json

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"radarr.Codec": "Codec",
1919
"radarr.Configure": "Configure",
2020
"radarr.Copy": "Copy",
21+
"radarr.CopyFiles": "Hardlink/Copy Files",
2122
"radarr.CopyFull": "Hardlink/Copy Files",
2223
"radarr.CutoffUnmet": "Cutoff Unmet",
2324
"radarr.DateAdded": "Date Added",
@@ -54,6 +55,8 @@
5455
"radarr.MonitorMovie": "Monitor Movie",
5556
"radarr.More": "More",
5657
"radarr.Move": "Move",
58+
"radarr.MoveFiles": "Move Files",
59+
"radarr.MoveFilesDescription": "Would you like to move the files?",
5760
"radarr.MoveFull": "Move Files",
5861
"radarr.Movie": "Movie",
5962
"radarr.Movies": "Movies",

0 commit comments

Comments
 (0)