Commit Graph

26 Commits

Author SHA1 Message Date
Luis Oliveira 50515ff9bd Stop duplicating files on repeat cartridge imports
fixes LS-2897
flag=none

test plan:
- Have the INST-FS plugin ON
- Have a canvas export package with at least one file
- Import the export package into a fresh course
- Import the same export package again.
- Check that the file wasn't duplicated
- (You could, after the first import, alter the
  attachment md5 column and put it's sha512 there,
  then theorically you'd be testing this, but Ideally
  you want instfs ON)

Change-Id: I0de79032d2ccd64e51cc09dea61b410aad43756f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/282779
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Robin Kuss <rkuss@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Luis Oliveira <luis.oliveira@instructure.com>
2022-02-03 15:07:56 +00:00
Cody Cutrer e73cf9ddf4 RuboCop: Style/HashSyntax
[skip-stages=Flakey]

auto-corrected

Change-Id: I9371a61046aee6b148f89dd434114a8ba2b1188c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279533
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
2021-11-25 14:02:35 +00:00
Cody Cutrer 55428b3440 RuboCop: Rails/Blank, Rails/Present
[skip-stages=Flakey]

auto-corrected

Change-Id: Ia0f5b0a40203d2023200683fa93ab4564372b271
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279084
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-20 21:09:43 +00:00
Cody Cutrer 3512a9557e RuboCop: Style/SafeNavigation
[skip-stages=Flakey]

auto-corrected

Change-Id: I0a907a6fa6229f05b4f756faf53a8dd2b18ea0c5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278213
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-16 06:36:38 +00:00
Cody Cutrer 2b3a208f9a RuboCop: Style/SymbolProc
[skip-stages=Flakey]

auto-corrected, with review for non-single-argument-callers.
there weren't any, but I did disable it anyway for one file where
it seemed to make the DSL less legible (QtiItems)

Change-Id: I1b4c43ffd899e656902981baac213ca394791b67
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278156
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-12 20:13:56 +00:00
Cody Cutrer c65d57737a RuboCop: Layout lib
Change-Id: I0655d9a9d750f2debd6378b03d8ddc1403ebc31b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274158
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-22 20:01:52 +00:00
Cody Cutrer 548a2a1732 update all invocations of send_later and friends to new syntax
Change-Id: I7f40ed058b50882121da69f0cb05966854b8e920
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/250924
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2020-10-30 19:13:54 +00:00
Cody Cutrer 06763dd519 add # frozen_string_literal: true for lib
Change-Id: I59b751cac52367a89e03f572477f0cf1d607b405
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251155
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-10-27 20:49:50 +00:00
James Williams 296717e708 prevent new migrations from rewriting attachment migration ids
test plan:
* have a blueprint course with a file
* sync to an associated course
* export the blueprint course
* import the export file directly
  into the associated course
* the associated course should have two files
* make a page in the blueprint with a link
 to the file
* syncing to the associated course should
create a page that still has a valid file link

* create a new course with a file
* copy the course into the blueprint
* sync the copied file to the associated course
* now copy the new course again into the
 associated course
* the associated course should have two files
* create another page in the blueprint referencing
 the copied file
* syncing to the associated course should
create a page that still has a valid file link

closes #LS-1496

Change-Id: I0549dd4b36c3235654b98f6cc825597b91878c2c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/248481
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
2020-09-28 18:26:40 +00:00
James Williams 61196bea80 run content migration attachment creation through instfs
test plan:
* have instfs enabled
* import a zip file into a course
* the attachments should have instfs_uuids

closes #LS-1285

Change-Id: I42e877e25dfcbd855bfc9e56b59cf969ea7d6ce0
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/244749
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
2020-08-12 20:49:52 +00:00
Simon Williams 4693861183 remove action_controller_test_process shim
it was used for two things:
- file_fixture_upload, which now comes from
  ActionDispatch::TestProcess::FixtureFile
- Rack::Test::UploadedFile which comes from the rack-test gem

Change-Id: I27957b410fcf4677dac77aed1b00b04dfd1b012e
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/222555
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-01-10 18:54:48 +00:00
James Williams 441b6c148d don't fail when importing a package with invalid attachments
test plan:
* import the package attached to the ticket
* it should not fail

closes #CNVS-38855

Change-Id: I7e3cd1115107bf8028d15ee0b53fbee288198b43
Reviewed-on: https://gerrit.instructure.com/124455
Tested-by: Jenkins
Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com>
QA-Review: Heath Hales <hhales@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2017-08-30 21:21:34 +00:00
James Williams 811c9df58a don't delete identical existing files on re-import
also fixes missing course image on re-import

test plan:
* create two courses with course images feature enabled
* add an image to one course
* export the course to a package
* import from the package into the other course twice
* the image should be imported correctly

closes #CNVS-37552

Change-Id: Iaf3dc169aad65ef4860e347cd8915e7bb3b40b81
Reviewed-on: https://gerrit.instructure.com/115762
Tested-by: Jenkins
QA-Review: Heath Hales <hhales@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2017-07-05 19:14:48 +00:00
Landon Wilkins 79215618d4 da licença part 29
add consistent license headers to all source files
(ruby, coffeescript, javascript)

except for vendor files

Change-Id: I49a8930917a609d3f118da1b20b51dedfd5d5903
Reviewed-on: https://gerrit.instructure.com/110053
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-04-27 21:59:53 +00:00
James Williams 75a6931534 handle failed attachments better in UnzipAttachment
don't let failed ones get added to fail on autosave

closes #CNVS-24093

Change-Id: I993d088388cfd6463d09db148ec498f7f6baad14
Reviewed-on: https://gerrit.instructure.com/65288
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2015-10-21 14:54:58 +00:00
Jeremy Stanley 8e134c6c20 import files as unpublished if usage rights required
test plan:
 0. enable "better file browsing" and "usage rights required"
    in a course
 1. upload and expand a zip file and confirm the files are
    unpublished initially
 2. confirm that a file imported from an imscc package is
    (a) unpublished in the new course if no usage rights
        were set in the source course, regardless of whether
        the file was published in the source course
    (b) unpublished in the new course if it was unpublished
        in the source course, regardless of whether usage
        rights were set in the source course
    (c) published in the new course if it was published in
        the source course and had usage rights set.
 3. repeat step 2, but with course copy instead

fixes CNVS-19620

Change-Id: I9a32adeafb94e4922ba95ad6466c72aca3fd3598
Reviewed-on: https://gerrit.instructure.com/52465
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2015-04-21 17:37:30 +00:00
James Williams a10c24c8f7 fix content_type inferring with explicit filename
Change-Id: I5fa1cc6f000f5b22a819dcbb717286be0735d641
Reviewed-on: https://gerrit.instructure.com/42926
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Dave Jungst <dave@instructure.com>
Product-Review: Bryan Madsen <bryan@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2014-10-17 22:00:30 +00:00
Anthus Williams bf208212d9 close temp files after upload
CNVS-11519

this fixes an error introduced in 
https://gerrit.instructure.com/#/c/28234/

test plan:
-try to upload a zipped directory containing lots
of files (for example, there is a dropbox link in
CNVS-11519 containing a file you can use
-while the upload is still in progress, try to upload
the same in a different course
-check that all files are uploaded, in each course

Change-Id: I373dfebe5dbc1f21e681d35e227037cb4a316676
Reviewed-on: https://gerrit.instructure.com/31933
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Anthus Williams <awilliams@instructure.com>
2014-03-24 16:15:08 +00:00
Anthus Williams 40c5c1f5f7 fix for rails3 refactoring of TestUploadedFile
in rails 3, ActionController::TestUploadedFile has
been moved to Rack::Test::UploadedFile. This commit
simply updates uses of TestUploadedFile to work
with this new structure

Change-Id: Ib31159c635f033a13908608dffeea88c8f719086
Reviewed-on: https://gerrit.instructure.com/28234
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Anthus Williams <awilliams@instructure.com>
QA-Review: Anthus Williams <awilliams@instructure.com>
2014-01-17 17:53:18 +00:00
Jacob Fugal fadf690fe0 require appropriate file for testing uploads
refs CNVS-9166

test-plan: N/A

Change-Id: Ie9ed104579961f0af67b9453ecc43670d48ecbac
Reviewed-on: https://gerrit.instructure.com/25736
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-29 19:02:55 +00:00
Jeremy Stanley 2deeda1b6b preserve module file items when overwriting files via zip
fixes #10583

see also #6233, the same bug, but non-zip case.  this changeset
makes zip uploads go through the same Attachment#handle_duplicates
workflow (but keeps the ability to batch-delete overwritten files).

test plan:
 * have a module with file items
 * overwrite the files via zip upload
 * make sure the module items don't disappear, and that they
   refer to the new version of the file

Change-Id: Ib5f530021285da3303b64bbd8d4b5b2746206ef6
Reviewed-on: https://gerrit.instructure.com/13720
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-09-14 13:54:38 -06:00
Bracken Mosbacker 9d5e9f4770 correctly replace modules and files on content migrations
Files weren't being replaced if they had a filename different
from their display_name.

The content_tags for modules are cleared before they are
imported so that only the items aren't duplicated.

Test Plan:
  * Import a package twice
	* The modules should be correct and not have 2 items for each item
	* The files should also not be duplicated

closes #10405

Change-Id: I3cb15c2530734185675a2b8bb9017bdf6ac35202
Reviewed-on: https://gerrit.instructure.com/13695
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-09-14 12:42:52 -06:00
Bracken Mosbacker 8e116eaf1e ensure that temp file handles are closed when uploading .zip files
Temp files are automatically closed when they are garbage
collected, but waiting for that to happen can cause too
many files to be open at once.

Test Plan:
 * Import a .zip or course import with lots of files
 * They should all be imported

closes #8726

Change-Id: I72b5a445259a330e27eccc645df4957a92ea1381
Reviewed-on: https://gerrit.instructure.com/11582
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
2012-06-18 09:12:06 -06:00
Zach Wily ae67b679e6 don't bypass filename escaping in FileInContext; fixes #6912
FileInContext (used by the zip importer) was bypassing the filename= setter
for Attachment, so when using attachment_fu, sanitize_filename was not getting
called on the filename. This resulted in us generating S3 urls with characters
in them like filename[0].txt. That normally worked fine. However, Firefox
would escape those characters when redirected to a URL like that, which would
cause a signature mismatch with S3.

This commit stops bypassing the filename= setter so files uploaded as zip
files and in migrations have escaped filenames. Because of difficulties
testing S3 attachments, the included spec is weak.

This also includes a migration that will rename attachments with []" in their
filenames, and make a copy of the S3 object to match.

There is also an unrelated spec refactor around faking out a portion of the
code about S3.

test plan:
 * Enable S3
 * Create a ZIP file with a file in it with a name like test[0].bin
 * Upload that ZIP file to your files are, choosing to unpack the ZIP contents
 * Verify that you can download the extracted file using firefox
 * Also verify that the attachment's filename is escaped in the db

Change-Id: I54fc0682b64a9e0021b4b41236f8cab168a0e56e
Reviewed-on: https://gerrit.instructure.com/8875
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
2012-02-22 21:46:00 -07:00
Brian Palmer dac5bdf0ce handle repeated qti imports of the same filename better, closes #4411
Change-Id: I61d67d5005b9073e5c937611014f0929e45562d1
Reviewed-on: https://gerrit.instructure.com/3367
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2011-04-29 12:33:31 -06:00
Brian Whitmer 8b8173dcc9 Initial commit.
closes #6988138
2011-01-31 18:57:29 -07:00