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

files: sync metadata on file edit #581

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

yashlamba
Copy link
Member

@yashlamba yashlamba commented Jul 2, 2024

We calculate image metadata when files are committed, which can happen on record edit as well.

Right now we only sync the file object version but not the metadata on edit - this PR fixes that.

@@ -360,7 +360,7 @@ def sync(self, src_files, delete_extras=True):
if obj_or_key in self:
del self[obj_or_key]
elif operation == "add":
self[obj_or_key.key] = obj_or_key
self[obj_or_key.key] = obj_or_key, dict(src_files[obj_or_key.key])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to understand what is happening: why do you need to cast it to dict? what type does src_files[obj_or_key.key] return ?

Copy link
Member Author

@yashlamba yashlamba Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the code a bit more to be clear, essentially, I am trying to replicate exactly what's happening here:

# Copy file record
if rf.metadata is not None:
self[key] = dst_obj, dict(rf)
else:
self[key] = dst_obj

src_files[obj_or_key.key] <- gives the latest file record and dict gives the "metadata"

@alejandromumo alejandromumo merged commit b868a35 into inveniosoftware:master Jul 5, 2024
12 checks passed
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.

4 participants