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
4a2f8604
Commit
4a2f8604
authored
Jun 01, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly migrate files
parent
e268960b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
app/uploaders/object_store_uploader.rb
app/uploaders/object_store_uploader.rb
+13
-5
No files found.
app/uploaders/object_store_uploader.rb
View file @
4a2f8604
require
'fog/aws'
require
'carrierwave/storage/fog'
class
ObjectStoreUploader
<
GitlabUploader
before
:store
,
:set_default_local_store
...
...
@@ -38,30 +41,35 @@ class ObjectStoreUploader < GitlabUploader
end
end
def
filename
super
||
file
&
.
filename
end
def
migrate!
(
new_store
)
raise
'Undefined new store'
unless
new_store
return
unless
object_store
!=
new_store
return
unless
file
# retrive file from current storag
e
current_file
=
fil
e
old_file
=
fil
e
old_store
=
object_stor
e
# change storage
self
.
object_store
=
new_store
# store file on a new storage
new_file
=
storage
.
store!
(
current
_file
)
new_file
=
storage
.
store!
(
old
_file
)
# since we change storage store the new storage
# in case of failure delete new file
begin
subject
.
save!
rescue
self
.
object_store
=
old_store
new_file
.
delete
end
# since we migrated file we can delete it now
current_file
.
delete
old_file
.
delete
end
def
move_to_store
...
...
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