mitodl / ocw-studio

Open Source Courseware authoring tool
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

Fix S3 path for Google Drive backfill #2089

Closed pt2302 closed 8 months ago

pt2302 commented 8 months ago

What are the relevant tickets?

Closes https://github.com/mitodl/ocw-studio/issues/2088.

Description (What does it do?)

This PR updates the call to download a file from S3 to strip a leading forward slash, if it exists. While MinIO properly handles a path with an extra leading forward slash, S3 does not.

How can this be tested?

Note: Testing is similar to testing for https://github.com/mitodl/ocw-studio/pull/2081, except that the AWS storage is used instead of MinIO. This can be done by setting the following variables in the OCW Studio .env file:

ENVIRONMENT=<anything except `dev`>
AWS_ACCESS_KEY_ID=<use value from RC>
AWS_SECRET_ACCESS_KEY=<use value from RC>
AWS_STORAGE_BUCKET_NAME=<use value from RC>
  1. Pick a legacy course that has no Google Drive content but does contain non-video resources for testing. An example is 24-915-linguistic-phonetics-fall-2015.
  2. Spin up OCW Studio with docker compose up.
  3. Run docker compose exec web ./manage.py backfill_gdrive_folder --filter <course name or short-id>.
  4. Check the Google Drive folder for the website to ensure that the resources have been uploaded correctly. Also, check the Django admin to ensure that DriveFile objects have been created for each resource.