Skip to content

Commit fdb1137

Browse files
teamconsryonakano
andauthored
move code out of trycatch block
Co-authored-by: Ryo Nakano <[email protected]>
1 parent 7d4b719 commit fdb1137

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/Services/M3U.vala

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44
*/
55

66
namespace Music.M3U {
7-
public bool is_playlist (File suspicious_file) {
8-
bool if_playlist = false;
7+
public bool is_playlist (File file) {
98
try {
10-
var info = suspicious_file.query_info (GLib.FileAttribute.STANDARD_CONTENT_TYPE, FileQueryInfoFlags.NONE);
11-
var mimetype = info.get_content_type () ?? "";
12-
if_playlist = mimetype == "audio/x-mpegurl";
13-
9+
var info = file.query_info (GLib.FileAttribute.STANDARD_CONTENT_TYPE, FileQueryInfoFlags.NONE);
1410
} catch (Error e) {
1511
warning (e.message);
12+
return false;
13+
}
14+
15+
var mimetype = info.get_content_type ();
16+
if (mimetype == null) {
17+
warning ("Failed to get content type");
18+
return false;
1619
}
1720

18-
return if_playlist;
21+
return mimetype == "audio/x-mpegurl";
1922
}
2023

2124
// Standard specification here: https://en.wikipedia.org/wiki/M3U

0 commit comments

Comments
 (0)