openownership / openownership.org-wagtail

Open Ownership Wagtail site.
Other
1 stars 1 forks source link

Uploading corrected PDFs with the same naming structure leads to showing original incorrect versions of documents #368

Closed StephenAbbott closed 1 year ago

StephenAbbott commented 1 year ago

Open Ownership often needs to delete uploaded PDFs from our document store due to issues being found with the documents, corrections being made and new versions being made ready for upload.

We also have a naming convention which we use for all uploaded documents.

Our communications team has reported an issue where they delete an original document fully, then reupload a new corrected version of the document with the same name but then it is the original uncorrected document which is shown when users go to the link.

Currently we are getting round this issue by slightly tweaking the names of the corrected documents so that the name/URL for the document is not exactly the same as the original.

Is there a way to fix this so that the corrected version and not the original is shown using the same naming convention?

drcongo commented 1 year ago

Hey @StephenAbbott - do you have an example? What you describe shouldn't actually be possible so I suspect it's loading a cached version but I'd need to verify.

StephenAbbott commented 1 year ago

@drcongo Checked in with the colleague who reported this to me. Summary of issue from her point of view:

I have just been playing with the UNODC advocacy doc as that is the latest example I have of this.

We had the latest version live (which has India / Greenland etc. in blue on the map on page 5 of the doc / labelled as page 4 because of the front cover) with the filename oo-submission-to-UNODC-2023- 06 (I had added a space before 06 to fix the problem I was facing)

I just went in checked that all versions of the pdf were deleted, including the one with a space before the 06 To see if I can show you an example, I was going to add the old version with the correct filename (oo-submission-to-UNODC-2023-06) and then delete it, and then add the new version with the same filename

When I went to add the old version (filename oo-submission-to-UNODC-2023-06) which does not have those countries in blue, when I did that, although I had deleted all pdfs from Wagtail, the new version is what I get when I go to download it

Incorrect version oo-submission-to-UNODC-2023-06.pdf

Correct version [Uploading oo-submission-to-UNODC-2023-06 (1).pdf…]()

Hope that helps

drcongo commented 1 year ago

That's even more confusing. This is that document in Wagtail - https://www.openownership.org/admin/documents/edit/766/

Screen Shot 2023-07-14 04 03 28 PM

Note, you can click on that file name and it'll show you the document. There's no need to delete documents from Wagtail if they need updating, you can just go to the document edit page above and click the Choose File button to upload the new one.

Screen Shot 2023-07-14 04 06 38 PM

Doing that, with a document with the same name, will overwrite the old one, and any place where that document is linked across the entire website will start serving the new one. If you upload a document with a different filename, they'll both still exist on the CDN, but any place that document is linked across the site will again serve the new one with the new filename.

The correct version link in your message is broken, but I think what might be happening is that your colleague is uploading the updated doc as a new document, and then deleting the old one. However, doing that is not going to update the links around the site where the original is attached, it will however break those links and they'll either disappear off the front end or return a 404. In between disappearing or 404ing though, there's potentially a period where cache is still holding the details of the old document. Overwriting the document file as outlined above is the only safe way to do this as this should invalidate the cache and the links around the site will continue to function. If you do somehow experience old documents still, you can clear the page cache in https://www.openownership.org/admin/cache/

StephenAbbott commented 1 year ago

Thanks @drcongo. Will confer with the team here about this

philgyford commented 1 year ago

@StephenAbbott Just wondering how this was going – is it still an issue? If so, any further info?

StephenAbbott commented 1 year ago

I think we can close this one