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

Question: how do I add a new version of a content file to an existing object? #5

Open
bcail opened this issue Feb 19, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@bcail
Copy link
Contributor

bcail commented Feb 19, 2019

If I have an existing object, and now I want to add a new version of a content file, what method do I call? Seems like Object.add_version expects a fully-created ocfl version directory, but I just want to add a new content file, without building a new ocfl version. Or do I have to create a new ocfl version first, and then add it to the object?

Thanks.

@bcail
Copy link
Contributor Author

bcail commented Feb 20, 2019

I guess I'm looking for the functionality that's in Birkland's ocfl client:

Copy some more stuff into the object (creating another version)

ocfl cp /etc/hosts test:stuff

@zimeon
Copy link
Owner

zimeon commented Feb 20, 2019

I haven't imagined the case of adding a single file use in what is written so far. I have only considered adding whole versions to an object (which is then managed with Object.add_version as you note)

@zimeon zimeon added the enhancement New feature or request label Apr 26, 2020
@bcail
Copy link
Contributor Author

bcail commented Aug 5, 2020

@zimeon would you be open to a PR that lets you add just one file (or multiple files) to an object, without constructing a full version directory?

@bcail
Copy link
Contributor Author

bcail commented Aug 5, 2020

I'd like to be able to do something like this:

with open(...) as f:
    write_file_to_object(object_id=test:1, file_obj=f, path=file1.txt)

So all I have to know is the file that I'm adding, and the object id. Would that make sense to add?

@zimeon
Copy link
Owner

zimeon commented Aug 5, 2020

I don't think I would want to add facilities to update an already written version because that doesn't follow the archival model of OCFL. I think it would be interesting to have a facility that added/removed/updated files starting from the current version, while creating a new version

@bcail
Copy link
Contributor Author

bcail commented Aug 5, 2020

sorry, yes, that's what I mean - create a new version (but having all the versioning, existing files, ... hidden where the user doesn't have to know about it)

@bcail
Copy link
Contributor Author

bcail commented Aug 6, 2020

ocfl-java has the idea of updating an object with a series of actions that result in a new version in the object:
https://github.com/UW-Madison-Library/ocfl-java/blob/master/ocfl-java-api/src/main/java/edu/wisc/library/ocfl/api/OcflObjectUpdater.java

So the user can add files, remove files, ... and a new version gets created with the results of those actions.

Should we do something similar here in this package? We could have actions that can be taken on an Object, and then a commit method, or a new object updater class that handles the actions and gets passed to an update_object method like ocfl-java does, ...

Any thoughts on the approach you'd like to see?

@zimeon
Copy link
Owner

zimeon commented Aug 18, 2020

Yes, I think a file-by-file updater to create a new version would be good. If we were cute it could be a context manager so one could do something like:

with ocfl_obj.new_version() as nv:
    nv.add_file(..)
    nv.rename_file(...)
    nv.delete_file(...)
    ...

where successful completion writes the new version and updates the inventory etc., an exception tidies up the incomplete new version creation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants