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
183b4233
Commit
183b4233
authored
Oct 01, 2019
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved specs, error messages and documentation
parent
81f821d3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
app/uploaders/gitlab_uploader.rb
app/uploaders/gitlab_uploader.rb
+2
-2
ee/lib/gitlab/geo/replication/base_transfer.rb
ee/lib/gitlab/geo/replication/base_transfer.rb
+3
-6
ee/spec/models/geo/upload_registry_spec.rb
ee/spec/models/geo/upload_registry_spec.rb
+1
-1
spec/models/upload_spec.rb
spec/models/upload_spec.rb
+13
-1
No files found.
app/uploaders/gitlab_uploader.rb
View file @
183b4233
...
@@ -99,10 +99,10 @@ class GitlabUploader < CarrierWave::Uploader::Base
...
@@ -99,10 +99,10 @@ class GitlabUploader < CarrierWave::Uploader::Base
end
end
end
end
# Used to replace an existing upload with
the informed file
without modifying stored metadata
# Used to replace an existing upload with
another +file+
without modifying stored metadata
# Use this method only to repair/replace an existing upload, or to upload to a Geo secondary node
# Use this method only to repair/replace an existing upload, or to upload to a Geo secondary node
#
#
# @param [CarrierWave::SanitizedFile] file
# @param [CarrierWave::SanitizedFile] file
that will replace existing upload
# @return CarrierWave::SanitizedFile
# @return CarrierWave::SanitizedFile
def
replace_file_without_saving!
(
file
)
def
replace_file_without_saving!
(
file
)
raise
ArgumentError
,
'should be a CarrierWave::SanitizedFile'
unless
file
.
is_a?
CarrierWave
::
SanitizedFile
raise
ArgumentError
,
'should be a CarrierWave::SanitizedFile'
unless
file
.
is_a?
CarrierWave
::
SanitizedFile
...
...
ee/lib/gitlab/geo/replication/base_transfer.rb
View file @
183b4233
...
@@ -199,13 +199,10 @@ module Gitlab
...
@@ -199,13 +199,10 @@ module Gitlab
# Upload file to Object Storage
# Upload file to Object Storage
uploader
.
replace_file_without_saving!
(
CarrierWave
::
SanitizedFile
.
new
(
temp_file
))
uploader
.
replace_file_without_saving!
(
CarrierWave
::
SanitizedFile
.
new
(
temp_file
))
log_info
(
"Successful downloaded"
,
filename:
filename
,
file_size_bytes:
file_size
)
log_info
(
"Successfully transferred"
,
file_type:
file_type
,
file_id:
file_id
,
file_size_bytes:
file_size
)
rescue
=>
e
rescue
=>
e
log_error
(
"Error downloading file"
,
error:
e
,
filename:
filename
,
url:
url
)
log_error
(
"Error transferring file"
,
error:
e
,
file_type:
file_type
,
file_id:
file_id
,
url:
url
)
return
failure_result
rescue
Errno
::
EEXIST
=>
e
log_error
(
"Destination file is a directory"
,
error:
e
,
filename:
filename
)
return
failure_result
return
failure_result
ensure
ensure
...
...
ee/spec/models/geo/upload_registry_spec.rb
View file @
183b4233
...
@@ -42,7 +42,7 @@ describe Geo::UploadRegistry, :geo, :geo_fdw do
...
@@ -42,7 +42,7 @@ describe Geo::UploadRegistry, :geo, :geo_fdw do
upload
=
create
(
:upload
,
:with_file
)
upload
=
create
(
:upload
,
:with_file
)
registry
=
create
(
:geo_upload_registry
,
:file
,
file_id:
upload
.
id
)
registry
=
create
(
:geo_upload_registry
,
:file
,
file_id:
upload
.
id
)
expect
(
registry
.
file
).
to
eq
(
"uploads/-/system/project/avatar/
#{
upload
.
id
}
/avatar.jpg"
)
expect
(
registry
.
file
).
to
eq
(
upload
.
path
)
end
end
it
'return "removed" message when the upload no longer exists'
do
it
'return "removed" message when the upload no longer exists'
do
...
...
spec/models/upload_spec.rb
View file @
183b4233
...
@@ -114,10 +114,22 @@ describe Upload do
...
@@ -114,10 +114,22 @@ describe Upload do
expect
(
uploader
.
upload
).
to
eq
(
subject
)
expect
(
uploader
.
upload
).
to
eq
(
subject
)
expect
(
uploader
.
mounted_as
).
to
eq
(
subject
.
send
(
:mount_point
))
expect
(
uploader
.
mounted_as
).
to
eq
(
subject
.
send
(
:mount_point
))
expect
(
uploader
.
file
).
to
be_nil
end
end
end
end
describe
'#needs_checksum??'
do
describe
'#retrieve_uploader'
do
it
'returns a uploader object with current uploader associated with and cache retrieved'
do
subject
=
build
(
:upload
)
uploader
=
subject
.
retrieve_uploader
expect
(
uploader
.
upload
).
to
eq
(
subject
)
expect
(
uploader
.
mounted_as
).
to
eq
(
subject
.
send
(
:mount_point
))
expect
(
uploader
.
file
).
not_to
be_nil
end
end
describe
'#needs_checksum?'
do
context
'with local storage'
do
context
'with local storage'
do
it
'returns true when no checksum exists'
do
it
'returns true when no checksum exists'
do
subject
=
create
(
:upload
,
:with_file
,
checksum:
nil
)
subject
=
create
(
:upload
,
:with_file
,
checksum:
nil
)
...
...
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