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
d61ee263
Commit
d61ee263
authored
Apr 04, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Gitlab::Geo::AvatarDownloader
parent
1683f020
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
29 deletions
+16
-29
app/services/geo/file_download_service.rb
app/services/geo/file_download_service.rb
+7
-12
lib/gitlab/geo/avatar_downloader.rb
lib/gitlab/geo/avatar_downloader.rb
+0
-13
lib/gitlab/geo/file_downloader.rb
lib/gitlab/geo/file_downloader.rb
+5
-1
lib/gitlab/geo/lfs_downloader.rb
lib/gitlab/geo/lfs_downloader.rb
+0
-1
spec/services/geo/file_download_service_spec.rb
spec/services/geo/file_download_service_spec.rb
+4
-2
No files found.
app/services/geo/file_download_service.rb
View file @
d61ee263
...
...
@@ -20,13 +20,10 @@ module Geo
private
def
downloader
begin
klass
=
Gitlab
::
Geo
.
const_get
(
"
#{
object_type
.
capitalize
}
Downloader"
)
klass
.
new
(
object_db_id
)
rescue
NameError
log
(
"unknown file type:
#{
object_type
}
"
)
raise
end
klass
=
"Gitlab::Geo::
#{
object_type
.
to_s
.
camelize
}
Downloader"
.
constantize
klass
.
new
(
object_db_id
)
rescue
NameError
Gitlab
::
Geo
::
FileDownloader
.
new
(
object_db_id
)
end
def
try_obtain_lease
...
...
@@ -41,14 +38,12 @@ module Geo
end
end
def
log
(
message
)
Rails
.
logger
.
info
"
#{
self
.
class
.
name
}
:
#{
message
}
"
end
def
update_registry
(
bytes_downloaded
)
transfer
=
Geo
::
FileRegistry
.
find_or_initialize_by
(
file_type:
object_type
,
file_id:
object_db_id
)
file_id:
object_db_id
)
transfer
.
bytes
=
bytes_downloaded
transfer
.
save
end
...
...
lib/gitlab/geo/avatar_downloader.rb
deleted
100644 → 0
View file @
1683f020
module
Gitlab
module
Geo
class
AvatarDownloader
<
FileDownloader
def
execute
upload
=
Upload
.
find_by_id
(
object_db_id
)
return
unless
upload
.
present?
transfer
=
::
Gitlab
::
Geo
::
FileTransfer
.
new
(
:avatar
,
upload
)
transfer
.
download_from_primary
end
end
end
end
lib/gitlab/geo/file_downloader.rb
View file @
d61ee263
...
...
@@ -12,7 +12,11 @@ module Gitlab
# Subclasses should return the number of bytes downloaded,
# or nil or -1 if a failure occurred.
def
execute
raise
NotImplementedError
upload
=
Upload
.
find_by_id
(
object_db_id
)
return
unless
upload
.
present?
transfer
=
::
Gitlab
::
Geo
::
FileTransfer
.
new
(
:avatar
,
upload
)
transfer
.
download_from_primary
end
end
end
...
...
lib/gitlab/geo/lfs_downloader.rb
View file @
d61ee263
...
...
@@ -3,7 +3,6 @@ module Gitlab
class
LfsDownloader
<
FileDownloader
def
execute
lfs_object
=
LfsObject
.
find_by_id
(
object_db_id
)
return
unless
lfs_object
.
present?
transfer
=
::
Gitlab
::
Geo
::
LfsTransfer
.
new
(
lfs_object
)
...
...
spec/services/geo/file_download_service_spec.rb
View file @
d61ee263
...
...
@@ -72,8 +72,10 @@ describe Geo::FileDownloadService, services: true do
end
end
it
'raises an error with bad object type'
do
expect
{
described_class
.
new
(
:bad
,
1
).
execute
}.
to
raise_error
(
NameError
)
context
'bad object type'
do
it
'does not track transfer'
do
expect
{
described_class
.
new
(
:bad
,
1
).
execute
}.
not_to
change
(
Geo
::
FileRegistry
,
:count
)
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