Skip to content
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

Object handling #1045

Merged
merged 16 commits into from
Oct 22, 2024
Merged

Object handling #1045

merged 16 commits into from
Oct 22, 2024

Conversation

axxel
Copy link
Contributor

@axxel axxel commented Oct 22, 2024

This is a set of patches mainly working on the reduction of the use of ptp_object_want() and especially eliminating it from inside loops over the object cache, which can cause 'problems', since the function may modify said object cache.

This should fix the issue discussed here for good.

axxel added 16 commits October 21, 2024 10:23
This enables to get some info from `gphoto2 --get-metadata` for Canons,
e.g.

<ObjectFileName>LZQ_0530.JPG</ObjectFileName>
<PersistantUniqueObjectIdentifier>Unknown type 10</PersistantUniqueObjectIdentifier>
<Name>LZQ_0530.JPG</Name>
<DateCreated>20241002T163923.0</DateCreated>
<DateModified>20241002T163922.0</DateModified>
<Width>1920</Width>
<Height>1280</Height>
<ImageBitDepth>24</ImageBitDepth>
Improved naming consistency with other find-like functions.
This removes another ptp_object_want() call.
* remove add_object()
* replace folder_to_storage() + find_folder_handle() macros with
  find_storage_and_handle_from_path() function
* introduce find_object_path() helper
* make find_child be const-correct w.r.t to 'const char*' path parameter
* handle EOSEvent_OjectInfoChanged together with
  PTP_EOSEvent_ObjectContentChanged
Having an implicit "move" that zeros out the source led to a painful
debugging session. This hidden behavior was a bad idea.

Adding array_init() for future use and minor fix of for_each().
…adata

This function contained basically another implementation of
find_object_path, which is now removed.
This removes 3 unnecessary "potential" alterations of the object cache.
Those 3 functions were calling ptp_list_folder to update the object cache
and then iterating over the object cache to find the children of some
specific handle, thereby calling ptp_object_want() which could potentially
remove objects from the list they were iterating over. This was explicitly
marked as "DANGEROUS", which it was.

This patch introduces a return parameter to ptp_list_folder, to let the
caller know, which handles it found. This does two things: a) it is a
potential performance improvement and b) the caller can iterate over a
fixed list of handles, instead of a potentially changing list of objects.
This also did away with the 'retry' logic that tried to deal with this
situation.

I further removed the special fetching of the root folder entries from
the camera_init function and other places and I removed the code
duplication between file_list_func and folder_list_func.
This removes the need to filter the list of StorageIDs in several places.
@msmeissn msmeissn merged commit 202ad51 into gphoto:master Oct 22, 2024
4 of 5 checks passed
@axxel axxel deleted the object-handling branch October 22, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants