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
fix: assetId not unique #93
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This is an interesting one. I think this hinges on one question: are "forked" assets, which are identical to one another in terms of content, and which share the same UUID, different assets? The way you fixed this assumes that they are, but my view is that they aren't. The asset UUID is generated by Architect when an asset is created. It can't be changed. and it has pretty strong likelihood of global uniqueness. As always, a UUID intends for a record to be unique within a system first and foremost. and it clearly passes that test. From that perspective, the fact that duplicated protocols have assets that share a UUID is actually a feature, not a bug. So given that, the real issue here is that we are failing on insertion when an asset with a UID already exists, rather than simply linking to it and saving ourself from creating a new db record and S3 bucket item. There are two obvious problems with doing this, though:
So either way we implement this we have a drawback. With your approach we are being space inefficient but we can track asset deletion. With my approach we are (I believe) maintaining the correct behaviour of the system, but we add a lot of complexity to the upload system (which has to work very differently if we can't just assume that assets can be uploaded right after validation completes) and the delete protocol functionality. Aside from that, there's one reason I don't like your fix specifically though: we are taking a UUID that we have already generated, but now know not to be unique, and we are just adding on some more uniqueness to the end. Why bother using it at all? Why not have our own unique identifier for this system, and store the current UUID in a different column (if we arent already) with more relaxed constraints? |
implements uploading assets, adding protocols to db, deleting protocols
Refactored the protocol upload and deletion functionality to allow protocols with assets that already exist to be uploaded. This change involves:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks great! Took me a little longer to understand, probably because I haven't coded in Fresco for a while 😄. I think we are handling the deleting process much efficient now. Anyway, I didn't spot any issue here, good work Caden
makes it so that there is only one db call. existingIds are passed directly in insertProtocol and connected. removes needing to return entire existing object asset.
Some protocols were failing to import because of a duplicate protocol issue. This was due to the way we use the assetManifest key as the assetId. We cannot actually assume that the assetManifest key is unique given that we allow protocols that are copies of one another if they have made changes.
This PR makes the assetId truly unique by appending a cuid to the key.