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

update_features: Fix update flag if hashes match #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

datengraben
Copy link

@Zverik @hixi thanks for the great tool!

I am pretty sure this is a bug. Since I'm using the tool for not so long, I am happy about a second pair of eyes/opinion on this. Maybe my usage is wrong, in uploading a Changes-JSON without a audit file, but my intention is to override only the changed features.

User-wise

The commit fixes the following case of updating features: You are uploading a set of features (Changes-JSON), where a ref exists, with a corresponding Feature object in the database

  • which already has been validated (and therefore Task objects exist)
  • which has not feat.audit data (and not data is in the Audit-File as well)
  • which has the same object data as in the input file (md5-hash match)

So at the moment all Feature related Task objects are deleted and the validates_count of the Feature is reset, despite the object contents are the same.

Technically

The change is pretty obvious.
If the computed content hash matches, update is set to True, despite that no update is needed. So I fix this, in setting this to False instead. It now prevents the reset of validates_count of database-features (that are the same in the set of upload-features) in the following line:

feat.validates_count = 0 if not feat.audit else 1

Alternatively you could remove the whole code line, since it's value is already initialized as False.

This fixes the case, if computed content hashes match, to set update = False instead of True. This prevents the reset of  `validates_count` of database-features, that are the same in the set of upload-features.
@datengraben
Copy link
Author

I removed the whole code-line, since it overrides the update flag, when feature hex values don't match.

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.

1 participant