Skip to content

Conversation

@monorkin
Copy link
Contributor

No description provided.

@monorkin monorkin force-pushed the import-export branch 2 times, most recently from ffabdbd to 9e37050 Compare January 16, 2026 13:18
def import_batch(files)
batch_data = files.map do |file|
data = load(file)
data["body"] = convert_gids_to_sgids(data["body"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we did try to collapse the record set classes a bit, we could handle this in a sort of before_insert step so that we don't need to supply a full implementation of import_batch to do it.

I also wonder if the export half of this is necessary (converting sgids to gids) or could we implicitly trust the signing on the way in while converting to new sgids? Effectively re-signing from an unknown key to the valid one. Since the transfer is effectively trusting that aspect of the input data anyway, it could be one less step. (Not sure if it makes much difference in practice or not though.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opted to go with a generic RecordSet and specific record sets. That kept the interface simple.

For the conversion. Yes, I could skip the SGID > GID > SGID dance, though this feels nicer.

@monorkin monorkin marked this pull request as ready for review January 21, 2026 12:30
ZipKit can read and write files directly from S3 which makes both imports and exports way more efficient in terms of disk usage.
During import, card return nil since it doesn't exist yet
Validate is an ActiveModel method, overriding it could have unintended side-effects so I opted to rename it
The old implementation loaded files into memory to provide an IO interface. This has the obvious downside of loading any file included in the import, e.g. a 10GB video file, into memory. ZipKit has no native IO object for reading but it provides all the necessary methods to implement one.
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