Skip to content

Conversation

@ryonakano
Copy link
Member

Fixes #829

The default value of previous-queue is a string array with one element that has a blank URI. This results last_session_uri.length is not 0 but 1, causing last_session_files has one File that has a blank URI.

public void restore_queue () {
// Restoring the queue overwrites the last played. So we need to retrieve it before taking care of the queue
var uri_last_played = settings.get_string ("uri-last-played");
var file_last_played = File.new_for_uri (uri_last_played);
var last_session_uri = settings.get_strv ("previous-queue");
var last_session_files = new File[last_session_uri.length];
for (var i = 0; i < last_session_uri.length; i++) {
var uri = last_session_uri[i];
var file = File.new_for_uri (uri);
last_session_files[i] = file;
}
var files_to_play = Application.loop_through_files (last_session_files);

causing the terminal warning here

if (FileUtils.test (file_path, FileTest.IS_DIR)) {

and causing the toast popup here

public void queue_files (File[] files) {
discoverer.start ();
int invalids = 0;
foreach (unowned var file in files) {
if (file.query_exists () && "audio" in ContentType.guess (file.get_uri (), null, null)) {
var audio_object = new AudioObject (file.get_uri ());
string? basename = file.get_basename ();
if (basename != null) {
audio_object.title = basename;
} else {
audio_object.title = audio_object.uri;
}
discoverer.discover_uri_async (audio_object.uri);
queue_liststore.append (audio_object);
} else {
invalids++;
continue;
}
}
if (invalids > 0) {
invalids_found (invalids);
}

@ryonakano ryonakano requested a review from a team September 1, 2025 12:42
@ryonakano ryonakano moved this to Needs review in OS 8.1.0 Sep 1, 2025
@ryonakano ryonakano mentioned this pull request Sep 1, 2025
3 tasks
@danirabbit danirabbit merged commit 622f117 into main Sep 1, 2025
3 checks passed
@danirabbit danirabbit deleted the ryonakano/fix-invalid-default-value branch September 1, 2025 14:29
@github-project-automation github-project-automation bot moved this from Needs review to Done in OS 8.1.0 Sep 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

The toast "1 invalid file was not added to the queue" and terminal warning is shown

3 participants