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
dd634fec
Commit
dd634fec
authored
Nov 21, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raises error when migration cannot happen so job is cancelled
parent
0bb65053
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
+5
-6
app/services/projects/hashed_storage/migrate_attachments_service.rb
...es/projects/hashed_storage/migrate_attachments_service.rb
+3
-1
spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb
...ojects/hashed_storage/migrate_attachments_service_spec.rb
+2
-5
No files found.
app/services/projects/hashed_storage/migrate_attachments_service.rb
View file @
dd634fec
module
Projects
module
HashedStorage
AttachmentMigrationError
=
Class
.
new
(
StandardError
)
class
MigrateAttachmentsService
<
BaseService
attr_reader
:logger
...
...
@@ -27,7 +29,7 @@ module Projects
if
File
.
exist?
(
new_path
)
logger
.
error
(
"Cannot migrate attachments from '
#{
old_path
}
' to '
#{
new_path
}
', target path already exist (PROJECT_ID=
#{
project
.
id
}
)"
)
r
eturn
r
aise
AttachmentMigrationError
,
"Target path '
#{
new_path
}
' already exist"
end
# Create hashed storage base path folder
...
...
spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb
View file @
dd634fec
...
...
@@ -49,13 +49,10 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
FileUtils
.
mkdir_p
(
base_path
(
hashed_storage
))
end
it
'
skips moving the file and goes to next
'
do
it
'
raises AttachmentMigrationError
'
do
expect
(
FileUtils
).
not_to
receive
(
:mv
).
with
(
base_path
(
legacy_storage
),
base_path
(
hashed_storage
))
service
.
execute
expect
(
File
.
exist?
(
base_path
(
legacy_storage
))).
to
be_truthy
expect
(
File
.
file?
(
old_path
)).
to
be_truthy
expect
{
service
.
execute
}.
to
raise_error
(
Projects
::
HashedStorage
::
AttachmentMigrationError
)
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