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

Consistency error while adding a new DataFile #42

Open
nvn-nil opened this issue Jun 6, 2023 · 0 comments
Open

Consistency error while adding a new DataFile #42

nvn-nil opened this issue Jun 6, 2023 · 0 comments

Comments

@nvn-nil
Copy link

nvn-nil commented Jun 6, 2023

Bug report

What is the current behavior?

If the current behavior is a bug, please provide any stack traces the steps reproduce and, if possible, a minimal demo of the problem.

Django model inheriting from AbstractSynchronisedDatastore throws a ConsistencyError while adding a new file (instance creation).

What is the expected behavior?

Adding a new file using the modal doesn't raise exception.

Other information

Explicitly passing the id to Datafile when update_from_store is False In AbstractSynchronisedDatastore seems to solve this for me.

df = Datafile(
path,
ignore_stored_metadata=False,
tags=self.get_tags_from_instance(),
labels=self.get_labels_from_instance(),
)

    def to_datafile(self, update_from_store=True, allow_no_location=False):
        ...
        if update_from_store:
            df = Datafile(path)
        else:
            df = Datafile(
                path,
                id=str(self.id), # <-- set the id; idk if this has implications in use cases other than on instance creation
                ignore_stored_metadata=False,
                tags=self.get_tags_from_instance(),
                labels=self.get_labels_from_instance(),
            )

Or maybe add a create_new_instance=False kwarg and create datafile with this.id as the id when called from AbstractSynchronisedDatastore.save method.

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

No branches or pull requests

1 participant