Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
3dc74378
Commit
3dc74378
authored
Nov 07, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow individual failures
parent
1bae010b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
16 deletions
+24
-16
lib/gitlab/background_migration/populate_untracked_uploads.rb
...gitlab/background_migration/populate_untracked_uploads.rb
+24
-16
No files found.
lib/gitlab/background_migration/populate_untracked_uploads.rb
View file @
3dc74378
...
...
@@ -97,28 +97,18 @@ module Gitlab
end
def
uploader
PATH_PATTERNS
.
each
do
|
path_pattern_map
|
if
path_relative_to_upload_dir
.
match
(
path_pattern_map
[
:pattern
])
return
path_pattern_map
[
:uploader
]
end
end
matching_pattern_map
[
:uploader
]
end
def
model_type
PATH_PATTERNS
.
each
do
|
path_pattern_map
|
if
path_relative_to_upload_dir
.
match
(
path_pattern_map
[
:pattern
])
return
path_pattern_map
[
:model_type
]
end
end
matching_pattern_map
[
:model_type
]
end
def
model_id
PATH_PATTERNS
.
each
do
|
path_pattern_map
|
matchd
=
path_relative_to_upload_dir
.
match
(
path_pattern_map
[
:pattern
])
matchd
=
path_relative_to_upload_dir
.
match
(
matching_pattern_map
[
:pattern
])
# If something is captured (matchd[1] is not nil), it is a model_id
return
matchd
[
1
]
if
matchd
&&
matchd
[
1
]
end
# If something is captured (matchd[1] is not nil), it is a model_id
return
matchd
[
1
]
if
matchd
[
1
]
# Only the FileUploader pattern will not match an ID
file_uploader_model_id
...
...
@@ -140,6 +130,16 @@ module Gitlab
private
def
matching_pattern_map
@matching_pattern_map
||=
PATH_PATTERNS
.
find
do
|
path_pattern_map
|
path_relative_to_upload_dir
.
match
(
path_pattern_map
[
:pattern
])
end
raise
"Unknown upload path pattern
\"
#{
path
}
\"
"
unless
@matching_pattern_map
@matching_pattern_map
end
def
file_uploader_model_id
pattern_to_capture_full_path
=
/\A(.+)
#{
FILE_UPLOADER_PATH_PATTERN
}
/
matchd
=
path_relative_to_upload_dir
.
match
(
pattern_to_capture_full_path
)
...
...
@@ -222,7 +222,15 @@ module Gitlab
files
=
UnhashedUploadFile
.
untracked
.
where
(
id:
start_id
..
end_id
)
files
.
each
do
|
unhashed_upload_file
|
unhashed_upload_file
.
ensure_tracked!
begin
unhashed_upload_file
.
ensure_tracked!
rescue
StandardError
=>
e
Rails
.
logger
.
warn
"Failed to add untracked file to uploads:
#{
e
.
message
}
"
# The untracked rows will remain in the DB. We will be able to see
# which ones failed to become tracked, and then we can decide what
# to do.
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment