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
6811caab
Commit
6811caab
authored
Dec 06, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include uploads to subgroups of a group for nodes with selective sync
parent
4814fe2c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
10 deletions
+20
-10
app/models/geo_node.rb
app/models/geo_node.rb
+1
-1
ee/app/finders/geo/attachment_registry_finder.rb
ee/app/finders/geo/attachment_registry_finder.rb
+1
-1
spec/ee/spec/finders/geo/attachment_registry_finder_spec.rb
spec/ee/spec/finders/geo/attachment_registry_finder_spec.rb
+18
-8
No files found.
app/models/geo_node.rb
View file @
6811caab
...
...
@@ -152,7 +152,7 @@ class GeoNode < ActiveRecord::Base
def
uploads
if
selective_sync?
uploads_table
=
Upload
.
arel_table
group_uploads
=
uploads_table
[
:model_type
].
eq
(
'Namespace'
).
and
(
uploads_table
[
:model_id
].
in
(
Gitlab
::
G
eo
.
current_node
.
namespace_ids
))
group_uploads
=
uploads_table
[
:model_type
].
eq
(
'Namespace'
).
and
(
uploads_table
[
:model_id
].
in
(
Gitlab
::
G
roupHierarchy
.
new
(
namespaces
).
base_and_descendants
.
pluck
(
:id
)
))
project_uploads
=
uploads_table
[
:model_type
].
eq
(
'Project'
).
and
(
uploads_table
[
:model_id
].
in
(
projects
.
pluck
(
:id
)))
other_uploads
=
uploads_table
[
:model_type
].
not_in
(
%w[Namespace Project]
)
...
...
ee/app/finders/geo/attachment_registry_finder.rb
View file @
6811caab
...
...
@@ -29,7 +29,7 @@ module Geo
if
selective_sync?
upload_table
=
upload_model
.
arel_table
group_uploads
=
upload_table
[
:model_type
].
eq
(
'Namespace'
).
and
(
upload_table
[
:model_id
].
in
(
current_node
.
namespace_ids
))
group_uploads
=
upload_table
[
:model_type
].
eq
(
'Namespace'
).
and
(
upload_table
[
:model_id
].
in
(
Gitlab
::
GroupHierarchy
.
new
(
current_node
.
namespaces
).
base_and_descendants
.
pluck
(
:id
)
))
project_uploads
=
upload_table
[
:model_type
].
eq
(
'Project'
).
and
(
upload_table
[
:model_id
].
in
(
current_node
.
projects
.
pluck
(
:id
)))
other_uploads
=
upload_table
[
:model_type
].
not_in
(
%w[Namespace Project]
)
...
...
spec/ee/spec/finders/geo/attachment_registry_finder_spec.rb
View file @
6811caab
...
...
@@ -8,6 +8,7 @@ describe Geo::AttachmentRegistryFinder, :geo, :truncate do
let
(
:secondary
)
{
create
(
:geo_node
)
}
let
(
:synced_group
)
{
create
(
:group
)
}
let
(
:synced_subgroup
)
{
create
(
:group
,
parent:
synced_group
)
}
let
(
:unsynced_group
)
{
create
(
:group
)
}
let
(
:synced_project
)
{
create
(
:project
,
group:
synced_group
)
}
let
(
:unsynced_project
)
{
create
(
:project
,
group:
unsynced_group
)
}
...
...
@@ -18,6 +19,7 @@ describe Geo::AttachmentRegistryFinder, :geo, :truncate do
let
(
:upload_4
)
{
create
(
:upload
,
model:
unsynced_project
)
}
let
(
:upload_5
)
{
create
(
:upload
,
model:
synced_project
)
}
let
(
:upload_6
)
{
create
(
:upload
,
:personal_snippet
)
}
let
(
:upload_7
)
{
create
(
:upload
,
model:
synced_subgroup
)
}
let
(
:lfs_object
)
{
create
(
:lfs_object
)
}
subject
{
described_class
.
new
(
current_node:
secondary
)
}
...
...
@@ -43,11 +45,12 @@ describe Geo::AttachmentRegistryFinder, :geo, :truncate do
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_2
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_3
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_6
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_7
.
id
)
create
(
:geo_file_registry
,
:lfs
,
file_id:
lfs_object
.
id
)
synced_attachments
=
subject
.
find_synced_attachments
expect
(
synced_attachments
.
pluck
(
:id
)).
to
match_array
([
upload_1
.
id
,
upload_2
.
id
,
upload_6
.
id
])
expect
(
synced_attachments
.
pluck
(
:id
)).
to
match_array
([
upload_1
.
id
,
upload_2
.
id
,
upload_6
.
id
,
upload_7
.
id
])
end
context
'with selective sync'
do
...
...
@@ -58,13 +61,14 @@ describe Geo::AttachmentRegistryFinder, :geo, :truncate do
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_4
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_5
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_6
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_7
.
id
)
create
(
:geo_file_registry
,
:lfs
,
file_id:
lfs_object
.
id
)
secondary
.
update_attribute
(
:namespaces
,
[
synced_group
])
synced_attachments
=
subject
.
find_synced_attachments
expect
(
synced_attachments
.
pluck
(
:id
)).
to
match_array
([
upload_1
.
id
,
upload_3
.
id
,
upload_6
.
id
])
expect
(
synced_attachments
.
pluck
(
:id
)).
to
match_array
([
upload_1
.
id
,
upload_3
.
id
,
upload_6
.
id
,
upload_7
.
id
])
end
end
end
...
...
@@ -81,11 +85,12 @@ describe Geo::AttachmentRegistryFinder, :geo, :truncate do
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_2
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_3
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_6
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_7
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:lfs
,
file_id:
lfs_object
.
id
,
success:
false
)
failed_attachments
=
subject
.
find_failed_attachments
expect
(
failed_attachments
.
pluck
(
:id
)).
to
match_array
([
upload_3
.
id
,
upload_6
.
id
])
expect
(
failed_attachments
.
pluck
(
:id
)).
to
match_array
([
upload_3
.
id
,
upload_6
.
id
,
upload_7
.
id
])
end
context
'with selective sync'
do
...
...
@@ -96,13 +101,14 @@ describe Geo::AttachmentRegistryFinder, :geo, :truncate do
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_4
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_5
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_6
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_7
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:lfs
,
file_id:
lfs_object
.
id
,
success:
false
)
secondary
.
update_attribute
(
:namespaces
,
[
synced_group
])
failed_attachments
=
subject
.
find_failed_attachments
expect
(
failed_attachments
.
pluck
(
:id
)).
to
match_array
([
upload_1
.
id
,
upload_3
.
id
,
upload_6
.
id
])
expect
(
failed_attachments
.
pluck
(
:id
)).
to
match_array
([
upload_1
.
id
,
upload_3
.
id
,
upload_6
.
id
,
upload_7
.
id
])
end
end
end
...
...
@@ -125,11 +131,12 @@ describe Geo::AttachmentRegistryFinder, :geo, :truncate do
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_2
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_3
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_6
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_7
.
id
)
create
(
:geo_file_registry
,
:lfs
,
file_id:
lfs_object
.
id
)
synced_attachments
=
subject
.
find_synced_attachments
expect
(
synced_attachments
).
to
match_array
([
upload_1
,
upload_2
,
upload_6
])
expect
(
synced_attachments
).
to
match_array
([
upload_1
,
upload_2
,
upload_6
,
upload_7
])
end
context
'with selective sync'
do
...
...
@@ -140,13 +147,14 @@ describe Geo::AttachmentRegistryFinder, :geo, :truncate do
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_4
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_5
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_6
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_7
.
id
)
create
(
:geo_file_registry
,
:lfs
,
file_id:
lfs_object
.
id
)
secondary
.
update_attribute
(
:namespaces
,
[
synced_group
])
synced_attachments
=
subject
.
find_synced_attachments
expect
(
synced_attachments
).
to
match_array
([
upload_1
,
upload_3
,
upload_6
])
expect
(
synced_attachments
).
to
match_array
([
upload_1
,
upload_3
,
upload_6
,
upload_7
])
end
end
end
...
...
@@ -163,11 +171,12 @@ describe Geo::AttachmentRegistryFinder, :geo, :truncate do
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_2
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_3
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_6
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_7
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:lfs
,
file_id:
lfs_object
.
id
,
success:
false
)
failed_attachments
=
subject
.
find_failed_attachments
expect
(
failed_attachments
).
to
match_array
([
upload_3
,
upload_6
])
expect
(
failed_attachments
).
to
match_array
([
upload_3
,
upload_6
,
upload_7
])
end
context
'with selective sync'
do
...
...
@@ -178,13 +187,14 @@ describe Geo::AttachmentRegistryFinder, :geo, :truncate do
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_4
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_5
.
id
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_6
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:avatar
,
file_id:
upload_7
.
id
,
success:
false
)
create
(
:geo_file_registry
,
:lfs
,
file_id:
lfs_object
.
id
,
success:
false
)
secondary
.
update_attribute
(
:namespaces
,
[
synced_group
])
failed_attachments
=
subject
.
find_failed_attachments
expect
(
failed_attachments
).
to
match_array
([
upload_1
,
upload_3
,
upload_6
])
expect
(
failed_attachments
).
to
match_array
([
upload_1
,
upload_3
,
upload_6
,
upload_7
])
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