Skip to content

atomic patch application #115

Open
Open
@johanneswilm

Description

@johanneswilm

Hey,
I have a situation in which I am restrained in terms of memory, so I patch the the original object in place. That works fine, except that the patches are user provided, so sometimes they don't apply fully. If the patch has multiple steps, only the first steps up to the failure are applied. Fro example:

[
    {op: 'add', path: '/attrs/language', value: 'de-DE'},  # 1, valid
    {op: 'add', path: '/attrs/country', value: 'US'},  # 2, valid
    {op: 'remove', path: '/fish'},  # 3, invalid
    {op: 'remove', path: '/attrs/copyright'} # 4, valid 
]

What happens in this situation is that 1 and 2 are applied, then an error is thrown. Unfortunately, it is not possible for me to find out which steps are applied or to undo those steps, as far as I can tell. Is there a way I can have it unapply 1 and 2 after 3 threw an error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions