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
9bb7abed
Commit
9bb7abed
authored
May 01, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix file_store for artifacts and lfs when saving
parent
9267ef0b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
20 additions
and
22 deletions
+20
-22
app/controllers/projects/lfs_storage_controller.rb
app/controllers/projects/lfs_storage_controller.rb
+1
-2
app/models/ci/job_artifact.rb
app/models/ci/job_artifact.rb
+1
-1
app/models/lfs_object.rb
app/models/lfs_object.rb
+1
-1
changelogs/unreleased/fix-file-store-artifacts-and-lfs.yml
changelogs/unreleased/fix-file-store-artifacts-and-lfs.yml
+5
-0
spec/controllers/projects/raw_controller_spec.rb
spec/controllers/projects/raw_controller_spec.rb
+2
-2
spec/models/lfs_object_spec.rb
spec/models/lfs_object_spec.rb
+1
-3
spec/services/projects/update_pages_service_spec.rb
spec/services/projects/update_pages_service_spec.rb
+6
-4
spec/uploaders/lfs_object_uploader_spec.rb
spec/uploaders/lfs_object_uploader_spec.rb
+3
-9
No files found.
app/controllers/projects/lfs_storage_controller.rb
View file @
9bb7abed
...
@@ -77,8 +77,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
...
@@ -77,8 +77,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
def
link_to_project!
(
object
)
def
link_to_project!
(
object
)
if
object
&&
!
object
.
projects
.
exists?
(
storage_project
.
id
)
if
object
&&
!
object
.
projects
.
exists?
(
storage_project
.
id
)
object
.
projects
<<
storage_project
object
.
lfs_objects_projects
.
create!
(
project:
storage_project
)
object
.
save!
end
end
end
end
end
end
app/models/ci/job_artifact.rb
View file @
9bb7abed
...
@@ -13,7 +13,7 @@ module Ci
...
@@ -13,7 +13,7 @@ module Ci
after_save
:update_project_statistics_after_save
,
if: :size_changed?
after_save
:update_project_statistics_after_save
,
if: :size_changed?
after_destroy
:update_project_statistics_after_destroy
,
unless: :project_destroyed?
after_destroy
:update_project_statistics_after_destroy
,
unless: :project_destroyed?
after_save
:update_file_store
after_save
:update_file_store
,
if: :file_changed?
scope
:with_files_stored_locally
,
->
{
where
(
file_store:
[
nil
,
::
JobArtifactUploader
::
Store
::
LOCAL
])
}
scope
:with_files_stored_locally
,
->
{
where
(
file_store:
[
nil
,
::
JobArtifactUploader
::
Store
::
LOCAL
])
}
...
...
app/models/lfs_object.rb
View file @
9bb7abed
...
@@ -11,7 +11,7 @@ class LfsObject < ActiveRecord::Base
...
@@ -11,7 +11,7 @@ class LfsObject < ActiveRecord::Base
mount_uploader
:file
,
LfsObjectUploader
mount_uploader
:file
,
LfsObjectUploader
after_save
:update_file_store
after_save
:update_file_store
,
if: :file_changed?
def
update_file_store
def
update_file_store
# The file.object_store is set during `uploader.store!`
# The file.object_store is set during `uploader.store!`
...
...
changelogs/unreleased/fix-file-store-artifacts-and-lfs.yml
0 → 100644
View file @
9bb7abed
---
title
:
Fix file_store for artifacts and lfs when saving
merge_request
:
author
:
type
:
fixed
spec/controllers/projects/raw_controller_spec.rb
View file @
9bb7abed
...
@@ -54,9 +54,9 @@ describe Projects::RawController do
...
@@ -54,9 +54,9 @@ describe Projects::RawController do
end
end
context
'and lfs uses object storage'
do
context
'and lfs uses object storage'
do
let
(
:lfs_object
)
{
create
(
:lfs_object
,
:with_file
,
oid:
'91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897'
,
size:
'1575078'
)
}
before
do
before
do
lfs_object
.
file
=
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"`/png"
)
lfs_object
.
save!
stub_lfs_object_storage
stub_lfs_object_storage
lfs_object
.
file
.
migrate!
(
LfsObjectUploader
::
Store
::
REMOTE
)
lfs_object
.
file
.
migrate!
(
LfsObjectUploader
::
Store
::
REMOTE
)
end
end
...
...
spec/models/lfs_object_spec.rb
View file @
9bb7abed
...
@@ -62,9 +62,7 @@ describe LfsObject do
...
@@ -62,9 +62,7 @@ describe LfsObject do
.
with
(
'LfsObjectUploader'
,
described_class
.
name
,
:file
,
kind_of
(
Numeric
))
.
with
(
'LfsObjectUploader'
,
described_class
.
name
,
:file
,
kind_of
(
Numeric
))
.
once
.
once
lfs_object
=
create
(
:lfs_object
)
create
(
:lfs_object
,
:with_file
)
lfs_object
.
file
=
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"`/png"
)
lfs_object
.
save!
end
end
end
end
end
end
...
...
spec/services/projects/update_pages_service_spec.rb
View file @
9bb7abed
...
@@ -123,11 +123,13 @@ describe Projects::UpdatePagesService do
...
@@ -123,11 +123,13 @@ describe Projects::UpdatePagesService do
expect
(
execute
).
not_to
eq
(
:success
)
expect
(
execute
).
not_to
eq
(
:success
)
end
end
it
'fails for empty file fails
'
do
context
'when using empty file
'
do
build
.
job_artifacts_archive
.
update_attributes
(
file:
empty_file
)
let
(
:file
)
{
empty_file
}
expect
{
execute
}
it
'fails to extract'
do
.
to
raise_error
(
Projects
::
UpdatePagesService
::
FailedToExtractError
)
expect
{
execute
}
.
to
raise_error
(
Projects
::
UpdatePagesService
::
FailedToExtractError
)
end
end
end
context
'when timeout happens by DNS error'
do
context
'when timeout happens by DNS error'
do
...
...
spec/uploaders/lfs_object_uploader_spec.rb
View file @
9bb7abed
...
@@ -46,8 +46,7 @@ describe LfsObjectUploader do
...
@@ -46,8 +46,7 @@ describe LfsObjectUploader do
end
end
describe
'remote file'
do
describe
'remote file'
do
let
(
:remote
)
{
described_class
::
Store
::
REMOTE
}
let
(
:lfs_object
)
{
create
(
:lfs_object
,
:object_storage
,
:with_file
)
}
let
(
:lfs_object
)
{
create
(
:lfs_object
,
file_store:
remote
)
}
context
'with object storage enabled'
do
context
'with object storage enabled'
do
before
do
before
do
...
@@ -57,16 +56,11 @@ describe LfsObjectUploader do
...
@@ -57,16 +56,11 @@ describe LfsObjectUploader do
it
'can store file remotely'
do
it
'can store file remotely'
do
allow
(
ObjectStorage
::
BackgroundMoveWorker
).
to
receive
(
:perform_async
)
allow
(
ObjectStorage
::
BackgroundMoveWorker
).
to
receive
(
:perform_async
)
store_file
(
lfs_object
)
lfs_object
expect
(
lfs_object
.
file_store
).
to
eq
remote
expect
(
lfs_object
.
file_store
).
to
eq
(
described_class
::
Store
::
REMOTE
)
expect
(
lfs_object
.
file
.
path
).
not_to
be_blank
expect
(
lfs_object
.
file
.
path
).
not_to
be_blank
end
end
end
end
end
end
def
store_file
(
lfs_object
)
lfs_object
.
file
=
fixture_file_upload
(
Rails
.
root
.
join
(
"spec/fixtures/dk.png"
),
"`/png"
)
lfs_object
.
save!
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