-
- Downloads
Refactor the uploaders
I've demoted the ObjectStoreUploader to a concern that is mixed in the concrete uploader classes that need to store files in a remote object store. I've been working on making the local -> remote migration working first, which has been trivial compared to the remote -> local one. The current implementation is heavily based on side-effects which makes the code brittle and hard to reason about. The current approach is to store the `store` field in the correct `Upload` model once a migration has been done. To retrieve the field I use the `has_many :uploads` relationship, with all the paths that a certain file may have `uploads.where(path: paths).last`. This as the drawback of adding a database query for every upload lookup, but I feel that the generalization of this behavior is worth it. We should be able to optimize this down the road quite easily.
Showing
- app/controllers/concerns/uploads_actions.rb 32 additions, 12 deletionsapp/controllers/concerns/uploads_actions.rb
- app/controllers/uploads_controller.rb 18 additions, 40 deletionsapp/controllers/uploads_controller.rb
- app/models/ci/build.rb 1 addition, 1 deletionapp/models/ci/build.rb
- app/models/lfs_object.rb 1 addition, 1 deletionapp/models/lfs_object.rb
- app/models/note.rb 2 additions, 0 deletionsapp/models/note.rb
- app/models/project.rb 8 additions, 0 deletionsapp/models/project.rb
- app/models/upload.rb 15 additions, 5 deletionsapp/models/upload.rb
- app/services/geo/lfs_object_deleted_event_store.rb 1 addition, 1 deletionapp/services/geo/lfs_object_deleted_event_store.rb
- app/services/projects/hashed_storage/migrate_attachments_service.rb 2 additions, 2 deletions...es/projects/hashed_storage/migrate_attachments_service.rb
- app/uploaders/attachment_uploader.rb 8 additions, 4 deletionsapp/uploaders/attachment_uploader.rb
- app/uploaders/avatar_uploader.rb 10 additions, 6 deletionsapp/uploaders/avatar_uploader.rb
- app/uploaders/file_mover.rb 3 additions, 4 deletionsapp/uploaders/file_mover.rb
- app/uploaders/file_uploader.rb 96 additions, 32 deletionsapp/uploaders/file_uploader.rb
- app/uploaders/gitlab_uploader.rb 30 additions, 29 deletionsapp/uploaders/gitlab_uploader.rb
- app/uploaders/job_artifact_uploader.rb 5 additions, 10 deletionsapp/uploaders/job_artifact_uploader.rb
- app/uploaders/legacy_artifact_uploader.rb 5 additions, 10 deletionsapp/uploaders/legacy_artifact_uploader.rb
- app/uploaders/lfs_object_uploader.rb 6 additions, 7 deletionsapp/uploaders/lfs_object_uploader.rb
- app/uploaders/namespace_file_uploader.rb 15 additions, 7 deletionsapp/uploaders/namespace_file_uploader.rb
- app/uploaders/personal_file_uploader.rb 27 additions, 13 deletionsapp/uploaders/personal_file_uploader.rb
- app/uploaders/records_uploads.rb 35 additions, 27 deletionsapp/uploaders/records_uploads.rb
Please register or sign in to comment