Bug #9682

Changes in information object slugs break finding aid download/delete

Added by José Raddaoui Marín about 6 years ago. Updated almost 6 years ago.

Status:VerifiedStart date:04/11/2016
Priority:MediumDue date:
Assignee:Dan Gillean% Done:

0%

Category:Information object
Target version:Release 2.3.0
Google Code Legacy ID: Tested version:2.3
Sponsored:No Requires documentation:

Description

AtoM currently uses the information object slug for the filename of the finding aid generated or uploaded, and it relies on that slug for the download and delete actions. Any change to the information object slug should be reflected in the finding aid filename, as far as I know this could happen in two places:

- Generate slugs action
- Rename form


Related issues

Related to Access to Memory (AtoM) - Feature #9627: Allow users to upload a PDF finding aid instead of genera... Verified 01/28/2016

History

#1 Updated by José Raddaoui Marín about 6 years ago

  • Related to Feature #9627: Allow users to upload a PDF finding aid instead of generating one from AtoM's descriptions added

#2 Updated by José Raddaoui Marín about 6 years ago

Or we could take another approach. We're storing now some properties from the finding aids in the database: transcript from uploaded PDFs and status to be able to filter between uploaded, generated and missing. We could create a 'finding_aid' table (1:1 with informations objects) and store those properties and the filename used when the finding aid was created. But then the slug and filename will not match after changes.

#3 Updated by Nick Wilkinson about 6 years ago

  • Assignee deleted (Nick Wilkinson)

#4 Updated by Nick Wilkinson about 6 years ago

  • Assignee set to Jesús García Crespo

#5 Updated by Jesús García Crespo about 6 years ago

  • Status changed from New to In progress

Quickest solution at this point is to rename the file. We should probably do this once the transaction is committed.

I've also drafted a better solution/clean-up based on Radda's suggestion in c#2.

Current features using downloads/:

  1. Finding aids are only made available basically if `isfile("downloads/$resourceSlug") is True`
  2. CSV exports are made available from the jobs page if `isfile("downloads/$jobId.zip") is True`

Problems:

- Form 1) breaks as described in #9682 when the slug of the resource is changed by the administrator
- Form 2) makes easy to discover non-published contents as downloads/ is publicy available and job IDs are autonumerics

Solution:

  1. Create `download` table with colums:
    object_id: { type: integer, required: true, foreignTable: object, foreignReference: id, onDelete: cascade }
    path: { type: varchar(1024), comment: "Relative to downloads/ directory" }
    type_id: { type: integer, foreignTable: term, foreignReference: id, onDelete: setnull }
    
  2. Implement QubitDownload
    #- Hook deletion trigger: try to delete downloads when its corresponding objects are deleted
    #- Should generate random paths
    #- Integrate with finding aids + dbmigration
    #- Integrate with CSV export + dbmigration
    #- OPTIONAL: never expose physical paths in URLs, use e.g. UUIDs with short TTLs (memcached) restricted to IP addresses, stream contents dynamically

Example of finding aid:

  1. User creates finding aid
  2. Worker generates PDF in /tmp (OS guarantees uniqueness of tmp file)
  3. UUID is generated (or other kind of randomly-generated str)
  4. Database transaction starts
  5. Tuple added to qubitDownload
  6. File is moved to downloads/ using UUID
  7. Database transaction ends
  8. User visits information object page
  9. AtoM checks existence in download table (type_id = $(finding_aid))
  10. Link is shown in description page...

#6 Updated by Jesús García Crespo about 6 years ago

Ran into this issue while I was trying to implement the quickest approach: #9855.

#7 Updated by Jesús García Crespo about 6 years ago

  • Status changed from In progress to Code Review
  • Assignee changed from Jesús García Crespo to Mike Gale

#9 Updated by Mike Gale about 6 years ago

  • Assignee changed from Mike Gale to Jesús García Crespo

#10 Updated by Mike Gale about 6 years ago

lgtm

#11 Updated by Jesús García Crespo about 6 years ago

  • Status changed from Code Review to QA/Review
  • Assignee changed from Jesús García Crespo to Dan Gillean

#12 Updated by Dan Gillean almost 6 years ago

  • Status changed from QA/Review to Verified

Also available in: Atom PDF