Additional check in --get-sidecars
authorColin Clark <[email protected]>
Tue, 25 Feb 2025 12:13:33 +0000 (12:13 +0000)
committerColin Clark <[email protected]>
Tue, 25 Feb 2025 12:13:33 +0000 (12:13 +0000)
Check if requested file exists. If not, make no output.

src/command-line-handling.cc

index b695e3761fd4228c1b91e5a40a9e9d124d48a060..06502a33e284ae08138c9fce4afacdb7ddc91875 100644 (file)
@@ -811,23 +811,27 @@ void gq_get_sidecars(GtkApplication *, GApplicationCommandLine *app_command_line
        const gchar *text;
        g_variant_dict_lookup(command_line_options_dict, "get-sidecars", "&s", &text);
        g_autofree gchar *filename = expand_tilde(text);
-       FileData *fd = file_data_new_group(filename);
 
-       GList *work;
-       if (fd->parent)
+       if (isfile(filename))
                {
-               fd = fd->parent;
-               }
-
-       g_application_command_line_print(app_command_line, "%s\n", fd->path);
+               FileData *fd = file_data_new_group(filename);
 
-       work = fd->sidecar_files;
+               GList *work;
+               if (fd->parent)
+                       {
+                       fd = fd->parent;
+                       }
 
-       while (work)
-               {
-               fd = static_cast<FileData *>(work->data);
-               work = work->next;
                g_application_command_line_print(app_command_line, "%s\n", fd->path);
+
+               work = fd->sidecar_files;
+
+               while (work)
+                       {
+                       fd = static_cast<FileData *>(work->data);
+                       work = work->next;
+                       g_application_command_line_print(app_command_line, "%s\n", fd->path);
+                       }
                }
 }