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
80f745f5
Commit
80f745f5
authored
Aug 27, 2019
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract FILE_NOT_FOUND_GEO_CODE to Replication module
parent
1acc39c6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
8 additions
and
9 deletions
+8
-9
ee/lib/gitlab/geo/replication.rb
ee/lib/gitlab/geo/replication.rb
+1
-0
ee/lib/gitlab/geo/replication/base_transfer.rb
ee/lib/gitlab/geo/replication/base_transfer.rb
+1
-1
ee/lib/gitlab/geo/replication/base_uploader.rb
ee/lib/gitlab/geo/replication/base_uploader.rb
+1
-3
ee/spec/lib/gitlab/geo/replication/file_transfer_spec.rb
ee/spec/lib/gitlab/geo/replication/file_transfer_spec.rb
+1
-1
ee/spec/lib/gitlab/geo/replication/job_artifact_transfer_spec.rb
.../lib/gitlab/geo/replication/job_artifact_transfer_spec.rb
+1
-1
ee/spec/lib/gitlab/geo/replication/lfs_transfer_spec.rb
ee/spec/lib/gitlab/geo/replication/lfs_transfer_spec.rb
+1
-1
ee/spec/requests/api/geo_spec.rb
ee/spec/requests/api/geo_spec.rb
+2
-2
No files found.
ee/lib/gitlab/geo/replication.rb
View file @
80f745f5
...
...
@@ -5,6 +5,7 @@ module Gitlab
module
Replication
USER_UPLOADS_OBJECT_TYPES
=
%i[attachment avatar file import_export namespace_file personal_file favicon]
.
freeze
UPLOAD_OBJECT_TYPE
=
:file
FILE_NOT_FOUND_GEO_CODE
=
'FILE_NOT_FOUND'
.
freeze
def
self
.
object_type_from_user_uploads?
(
object_type
)
USER_UPLOADS_OBJECT_TYPES
.
include?
(
object_type
.
to_sym
)
...
...
ee/lib/gitlab/geo/replication/base_transfer.rb
View file @
80f745f5
...
...
@@ -127,7 +127,7 @@ module Gitlab
end
def
code_file_not_found?
(
geo_code
)
geo_code
==
Gitlab
::
Geo
::
Replication
::
F
ileUploader
::
F
ILE_NOT_FOUND_GEO_CODE
geo_code
==
Gitlab
::
Geo
::
Replication
::
FILE_NOT_FOUND_GEO_CODE
end
def
default_permissions
...
...
ee/lib/gitlab/geo/replication/base_uploader.rb
View file @
80f745f5
...
...
@@ -6,8 +6,6 @@ module Gitlab
class
BaseUploader
include
LogHelpers
FILE_NOT_FOUND_GEO_CODE
=
'FILE_NOT_FOUND'
.
freeze
attr_reader
:object_db_id
,
:message
def
initialize
(
object_db_id
,
message
)
...
...
@@ -31,7 +29,7 @@ module Gitlab
def
file_not_found
(
resource
)
{
code: :not_found
,
geo_code:
FILE_NOT_FOUND_GEO_CODE
,
geo_code:
Replication
::
FILE_NOT_FOUND_GEO_CODE
,
message:
"
#{
resource
.
class
.
name
}
#
#{
resource
.
id
}
file not found"
}
end
...
...
ee/spec/lib/gitlab/geo/replication/file_transfer_spec.rb
View file @
80f745f5
...
...
@@ -66,7 +66,7 @@ describe Gitlab::Geo::Replication::FileTransfer do
expect
(
FileUtils
).
not_to
receive
(
:mv
).
with
(
anything
,
upload
.
absolute_path
).
and_call_original
response
=
double
(
:response
,
success?:
false
,
code:
404
,
msg:
"No such file"
)
expect
(
File
).
to
receive
(
:read
).
and_return
(
"{
\"
geo_code
\"
:
\"
#{
Gitlab
::
Geo
::
Replication
::
F
ileUploader
::
F
ILE_NOT_FOUND_GEO_CODE
}
\"
}"
)
expect
(
File
).
to
receive
(
:read
).
and_return
(
"{
\"
geo_code
\"
:
\"
#{
Gitlab
::
Geo
::
Replication
::
FILE_NOT_FOUND_GEO_CODE
}
\"
}"
)
expect
(
Gitlab
::
HTTP
).
to
receive
(
:get
).
and_return
(
response
)
result
=
subject
.
download_from_primary
...
...
ee/spec/lib/gitlab/geo/replication/job_artifact_transfer_spec.rb
View file @
80f745f5
...
...
@@ -71,7 +71,7 @@ describe Gitlab::Geo::Replication::JobArtifactTransfer, :geo do
it
'returns a failed result indicating primary_missing_file'
do
expect
(
FileUtils
).
not_to
receive
(
:mv
).
with
(
anything
,
job_artifact
.
file
.
path
).
and_call_original
response
=
double
(
:response
,
success?:
false
,
code:
404
,
msg:
"No such file"
)
expect
(
File
).
to
receive
(
:read
).
and_return
(
"{
\"
geo_code
\"
:
\"
#{
Gitlab
::
Geo
::
Replication
::
F
ileUploader
::
F
ILE_NOT_FOUND_GEO_CODE
}
\"
}"
)
expect
(
File
).
to
receive
(
:read
).
and_return
(
"{
\"
geo_code
\"
:
\"
#{
Gitlab
::
Geo
::
Replication
::
FILE_NOT_FOUND_GEO_CODE
}
\"
}"
)
expect
(
Gitlab
::
HTTP
).
to
receive
(
:get
).
and_return
(
response
)
result
=
subject
.
download_from_primary
...
...
ee/spec/lib/gitlab/geo/replication/lfs_transfer_spec.rb
View file @
80f745f5
...
...
@@ -49,7 +49,7 @@ describe Gitlab::Geo::Replication::LfsTransfer do
it
'returns a failed result indicating primary_missing_file'
do
expect
(
FileUtils
).
not_to
receive
(
:mv
).
with
(
anything
,
lfs_object
.
file
.
path
).
and_call_original
response
=
double
(
:response
,
success?:
false
,
code:
404
,
msg:
"No such file"
)
expect
(
File
).
to
receive
(
:read
).
and_return
(
"{
\"
geo_code
\"
:
\"
#{
Gitlab
::
Geo
::
Replication
::
F
ileUploader
::
F
ILE_NOT_FOUND_GEO_CODE
}
\"
}"
)
expect
(
File
).
to
receive
(
:read
).
and_return
(
"{
\"
geo_code
\"
:
\"
#{
Gitlab
::
Geo
::
Replication
::
FILE_NOT_FOUND_GEO_CODE
}
\"
}"
)
expect
(
Gitlab
::
HTTP
).
to
receive
(
:get
).
and_return
(
response
)
result
=
subject
.
download_from_primary
...
...
ee/spec/requests/api/geo_spec.rb
View file @
80f745f5
...
...
@@ -178,7 +178,7 @@ describe API::Geo do
get
api
(
"/geo/transfers/file/
#{
upload
.
id
}
"
),
headers:
req_header
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
json_response
[
'geo_code'
]).
to
eq
(
Gitlab
::
Geo
::
Replication
::
F
ileUploader
::
F
ILE_NOT_FOUND_GEO_CODE
)
expect
(
json_response
[
'geo_code'
]).
to
eq
(
Gitlab
::
Geo
::
Replication
::
FILE_NOT_FOUND_GEO_CODE
)
end
end
end
...
...
@@ -229,7 +229,7 @@ describe API::Geo do
get
api
(
"/geo/transfers/lfs/
#{
lfs_object
.
id
}
"
),
headers:
req_header
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
json_response
[
'geo_code'
]).
to
eq
(
Gitlab
::
Geo
::
Replication
::
F
ileUploader
::
F
ILE_NOT_FOUND_GEO_CODE
)
expect
(
json_response
[
'geo_code'
]).
to
eq
(
Gitlab
::
Geo
::
Replication
::
FILE_NOT_FOUND_GEO_CODE
)
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