Skip to content

Consistency error while adding a new DataFile #42

@nvn-nil

Description

@nvn-nil

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions