diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-06-04 20:50:57 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-06-17 11:25:40 -0300 |
commit | 44e1915d4f0e20cf445196ccc7e1d279c75ef0ce (patch) | |
tree | 2619dcea9bf96af77023f8fb9a0b84cd5a8f69ee /app/helpers | |
parent | e398409a74db7f3ca1c90d3b056b3a84ebb1b6cf (diff) | |
download | gitlab-ce-44e1915d4f0e20cf445196ccc7e1d279c75ef0ce.tar.gz |
Persist tmp snippet uploads
It persist temporary personal snippets under
user/:id namespaces temporarily while creating
a upload record to track it. If an user gets removed
while it's still a tmp upload, it also gets removed.
If the tmp upload is sent, the upload gets moved to
personal_snippets/:id as before. The upload record
also gets updated to the new model type as well.
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/snippets_helper.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/helpers/snippets_helper.rb b/app/helpers/snippets_helper.rb index ecb2b2d707b..6ccc1fb2ed1 100644 --- a/app/helpers/snippets_helper.rb +++ b/app/helpers/snippets_helper.rb @@ -1,6 +1,16 @@ # frozen_string_literal: true module SnippetsHelper + def snippets_upload_path(snippet, user) + return unless user + + if snippet&.persisted? + upload_path('personal_snippet', id: snippet.id) + else + upload_path('user', id: user.id) + end + end + def reliable_snippet_path(snippet, opts = nil) if snippet.project_id? project_snippet_path(snippet.project, snippet, opts) |