-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a remote command for batch duplicate finding. #1524
base: master
Are you sure you want to change the base?
Conversation
src/remote.cc
Outdated
pid_t pid = fork(); | ||
if (pid == -1) { | ||
perror("fork"); | ||
exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit()
is not called directly from anywhere else in this file, and geeqie does not generally use perror
. The best course of action here is likely to log an error and return. See an example here:
Line 541 in 8cdab99
static void gr_lw_id(const gchar *text, GIOChannel *, gpointer) |
With that said, it's probably a lot safer to use an API like https://docs.gtk.org/gio/ctor.Subprocess.new.html instead of fork
ing directly. That said, @qarkai is our resident expert on glib APIs, so I would defer to him.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Geeqie uses g_spawn_async_with_pipes()
for external editor. See editor_command_one()
in src/editors.cc:1053
.
In the latest commit, the command line handling has changed. The attached .diff are the changes I think are necessary to conform with the new code: |
Revised .diff file. You can run the project static tests locally before making a pull request by: |
Thank you for the reviews @xsdg and @qarkai and the rebase @caclark! Here's a new iteration, where I also removed the need to run in "remote" mode. I think I addressed all the comments, apart from one, about using
Example usage:
and with debug output:
|
I suggest you consider changing option There should be entries for the three command line long options in If you wish the I have some other comments but it will be a few days before I write them down. |
@porridge @ anyone else I think there may be another way to solve this problem. It would involve some new features that may or may not be possible. The adding of files to the Dupes Window is a bit messy. Either by drag-and-drop or right click on files or directory - but this does not work as I expect at the moment (the right-click feature opens a new Dupes Window each time, which I do not think is correct).
When the Dupes Window is open the user has the possibility to change the comparison type, the image rotation mode and other options. The selected data may be Exported to a comma-separated or tab-separated file via a right-click in the Dupes Window.
The plugins are available via a right-click in the Dupes window. With that pretty much anything can be achieved, and might make
|
I believe they are there already in the
I think it's better to require the user to explicitly provide the program, in case it is destructive and the user forgot what it was set to last. |
@caclark, sounds like what you are suggesting would be more discoverable for a typical GUI user. OTOH it might be less convenient for use in scripted, automated workflows. But most importantly from my perspective - I don't feel anywhere as competent as would be required to implement what you described 😅 |
@porridge After compiling, from a terminal window run From another terminal window run Run The advantages I see are: If this is an acceptable solution, the |
It would be hard to incorporate this kind of usage (run a GUI-dependant geeqie session and while it's running, launch another process) into my workflow. Not impossible, but the changing window focus and juggling a process running in the background are tricky to handle. FTR my use case is an automated pipeline that:
Also, simple text format makes it hard to reliably handle filenames which in principle can contain arbitrary whitespace characters. This could be done in a somewhat standard way using JSON format for example, but even then the need to post-process that iin order to pass further down the pipeline is yet another hurdle. This is why I found the feature of running a separate user specified command on each set of duplicates in turn particularly attractive.
Yes, that would indeed be nice. While it was super easy to reuse the algorithm for comparing two images, when I tried to reuse the logic that geeqie uses internally to process a whole list of files I got completely lost in the sources 😅 |
@@ -407,6 +411,114 @@ void gq_delay(GtkApplication *, GApplicationCommandLine *app_command_line, GVari | |||
options->slideshow.delay = static_cast<gint>(n * 10.0 + 0.01); | |||
} | |||
|
|||
void gq_duplicates_process(GtkApplication *, GApplicationCommandLine *, GVariantDict *, GList *file_list) | |||
{ | |||
std::map<std::string, std::unique_ptr<pic_equiv>> pics; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unique_ptr
seems redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @qarkai
I addressed the other comments, but with my rudimentary C++ skills I cannot see how to address this one?
- replacing with
pic_equiv *
would leak memory, right? - replacing with
pic_equiv
does not work because the assignment operator is deleted:
../src/command-line-handling.cc: In function ‘void {anonymous}::gq_duplicates_process(GtkApplication*,
GApplicationCommandLine*, GVariantDict*, GList*)’:
../src/command-line-handling.cc:422:42: error: use of deleted function ‘pic_equiv& pic_equiv::operator=(const pic_equiv&)’
422 | pics[name] = pic_equiv(fd);
and it's deleted because of the sim
member.
It also seems to me like using a pointer is better than copying the sim structure around...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. ImageSimilarityData
lacks constructors and moving operator. Ok. let's stay with unique_ptr
for now.
@porridge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@@ -407,6 +411,114 @@ void gq_delay(GtkApplication *, GApplicationCommandLine *app_command_line, GVari | |||
options->slideshow.delay = static_cast<gint>(n * 10.0 + 0.01); | |||
} | |||
|
|||
void gq_duplicates_process(GtkApplication *, GApplicationCommandLine *, GVariantDict *, GList *file_list) | |||
{ | |||
std::map<std::string, std::unique_ptr<pic_equiv>> pics; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. ImageSimilarityData
lacks constructors and moving operator. Ok. let's stay with unique_ptr
for now.
explicit pic_equiv(char const *cname); | ||
~pic_equiv(); | ||
pic_equiv(const pic_equiv& other) = delete; | ||
pic_equiv& operator=(const pic_equiv& other) = delete; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess pic_equiv
assignment operator could be restored using shared_ptr
with custom deleter for sim
member.
And one more thing. Would you mind renaming class to PicEquiv
or something for naming consistency?
Here is my first stab at it. I know I at least need to adjust for the accepted coding style, but please let me know if there are any other major things that need changing.
Based on https://github.com/porridge/image-duplicate-finder
Closes: #1520