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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
15e3ecc8
Commit
15e3ecc8
authored
Apr 13, 2020
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix wrong file type for source uploads
parent
845824e0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
8 deletions
+52
-8
ee/app/finders/geo/attachment_registry_finder.rb
ee/app/finders/geo/attachment_registry_finder.rb
+21
-8
ee/spec/finders/geo/attachment_registry_finder_spec.rb
ee/spec/finders/geo/attachment_registry_finder_spec.rb
+31
-0
No files found.
ee/app/finders/geo/attachment_registry_finder.rb
View file @
15e3ecc8
...
...
@@ -34,13 +34,14 @@ module Geo
Upload
end
# Returns untracked
IDs as well as tracked ID
s that are unused.
# Returns untracked
uploads as well as tracked upload
s that are unused.
#
# Untracked
IDs are model IDs that are supposed to be synced but don't yet
# have a registry entry.
# Untracked
uploads is an array where each item is a tuple of [id, file_type]
#
that is supposed supposed to be synced but don't yet
have a registry entry.
#
# Unused tracked IDs are model IDs that are not supposed to be synced but
# already have a registry entry. For example:
# Unused uploads is an array where each item is a tuple of [id, file_type]
# that is not supposed to be synced but already have a registry entry. For
# example:
#
# - orphaned registries
# - records that became excluded from selective sync
...
...
@@ -50,10 +51,22 @@ module Geo
# We compute both sets in this method to reduce the number of DB queries
# performed.
#
# @return [Array] the first element is an Array of untracked IDs, and the second element is an Array of tracked IDs that are unused
# @return [Array] the first element is an Array of untracked uploads, and the
# second element is an Array of tracked uploads that are unused.
# For example: [[[1, 'avatar'], [5, 'file']], [[3, 'attachment']]]
def
find_registry_differences
(
range
)
source
=
attachments
(
fdw:
false
).
where
(
id:
range
).
pluck
(
::
Upload
.
arel_table
[
:id
],
::
Upload
.
arel_table
[
:uploader
])
# rubocop:disable CodeReuse/ActiveRecord
tracked
=
Geo
::
UploadRegistry
.
where
(
file_id:
range
).
pluck
(
:file_id
,
:file_type
)
# rubocop:disable CodeReuse/ActiveRecord
# rubocop:disable CodeReuse/ActiveRecord
source
=
attachments
(
fdw:
false
)
.
id_in
(
range
)
.
pluck
(
::
Upload
.
arel_table
[
:id
],
::
Upload
.
arel_table
[
:uploader
])
.
map!
{
|
id
,
uploader
|
[
id
,
uploader
.
sub
(
/Uploader\z/
,
''
).
underscore
]
}
tracked
=
Geo
::
UploadRegistry
.
model_id_in
(
range
)
.
pluck
(
:file_id
,
:file_type
)
# rubocop:enable CodeReuse/ActiveRecord
untracked
=
source
-
tracked
unused_tracked
=
tracked
-
source
...
...
ee/spec/finders/geo/attachment_registry_finder_spec.rb
View file @
15e3ecc8
...
...
@@ -339,5 +339,36 @@ describe Geo::AttachmentRegistryFinder, :geo, :geo_fdw do
end
end
end
describe
'#find_registry_differences'
do
it
'returns untracked IDs as well as tracked IDs that are unused'
,
:aggregate_failures
do
max_id
=
Upload
.
maximum
(
:id
)
create
(
:geo_upload_registry
,
:avatar
,
file_id:
upload_synced_group
.
id
)
create
(
:geo_upload_registry
,
:file
,
file_id:
upload_issuable_synced_nested_project
.
id
)
create
(
:geo_upload_registry
,
:avatar
,
file_id:
upload_synced_project
.
id
)
create
(
:geo_upload_registry
,
:personal_file
,
file_id:
upload_personal_snippet
.
id
)
create
(
:geo_upload_registry
,
:avatar
,
file_id:
upload_remote_synced_project
.
id
)
unused_registry_1
=
create
(
:geo_upload_registry
,
:attachment
,
file_id:
max_id
+
1
)
unused_registry_2
=
create
(
:geo_upload_registry
,
:personal_file
,
file_id:
max_id
+
2
)
range
=
1
..
(
max_id
+
2
)
untracked
,
unused
=
subject
.
find_registry_differences
(
range
)
expected_untracked
=
[
[
upload_unsynced_group
.
id
,
'avatar'
],
[
upload_unsynced_project
.
id
,
'avatar'
],
[
upload_remote_unsynced_project
.
id
,
'avatar'
],
[
upload_remote_synced_group
.
id
,
'avatar'
]
]
expected_unused
=
[
[
unused_registry_1
.
file_id
,
'attachment'
],
[
unused_registry_2
.
file_id
,
'personal_file'
]
]
expect
(
untracked
).
to
match_array
(
expected_untracked
)
expect
(
unused
).
to
match_array
(
expected_unused
)
end
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