BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
67b58ffd
Commit
67b58ffd
authored
Nov 22, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of tracked field
It makes a debugging slightly easier, but is not necessary, and is a waste of resources.
parent
a9155a94
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
29 deletions
+7
-29
populate_untracked_uploads.rb
...gitlab/background_migration/populate_untracked_uploads.rb
+3
-11
prepare_untracked_uploads.rb
lib/gitlab/background_migration/prepare_untracked_uploads.rb
+0
-2
populate_untracked_uploads_spec.rb
...b/background_migration/populate_untracked_uploads_spec.rb
+4
-16
No files found.
lib/gitlab/background_migration/populate_untracked_uploads.rb
View file @
67b58ffd
...
@@ -50,14 +50,10 @@ module Gitlab
...
@@ -50,14 +50,10 @@ module Gitlab
}
}
].
freeze
].
freeze
scope
:untracked
,
->
{
where
(
tracked:
false
)
}
def
ensure_tracked!
def
ensure_tracked!
return
if
persisted?
&&
tracked?
add_to_uploads
unless
in_uploads?
add_to_uploads
unless
in_uploads?
mark_as_tracked
delete
end
end
def
in_uploads?
def
in_uploads?
...
@@ -79,10 +75,6 @@ module Gitlab
...
@@ -79,10 +75,6 @@ module Gitlab
)
)
end
end
def
mark_as_tracked
update!
(
tracked:
true
)
end
def
upload_path
def
upload_path
# UntrackedFile#path is absolute, but Upload#path depends on uploader
# UntrackedFile#path is absolute, but Upload#path depends on uploader
if
uploader
==
'FileUploader'
if
uploader
==
'FileUploader'
...
@@ -197,7 +189,7 @@ module Gitlab
...
@@ -197,7 +189,7 @@ module Gitlab
def
perform
(
start_id
,
end_id
)
def
perform
(
start_id
,
end_id
)
return
unless
migrate?
return
unless
migrate?
files
=
UntrackedFile
.
untracked
.
where
(
id:
start_id
..
end_id
)
files
=
UntrackedFile
.
where
(
id:
start_id
..
end_id
)
files
.
each
do
|
untracked_file
|
files
.
each
do
|
untracked_file
|
begin
begin
untracked_file
.
ensure_tracked!
untracked_file
.
ensure_tracked!
...
@@ -220,7 +212,7 @@ module Gitlab
...
@@ -220,7 +212,7 @@ module Gitlab
end
end
def
drop_temp_table_if_finished
def
drop_temp_table_if_finished
UntrackedFile
.
connection
.
drop_table
(
:untracked_files_for_uploads
)
if
UntrackedFile
.
untracked
.
empty?
UntrackedFile
.
connection
.
drop_table
(
:untracked_files_for_uploads
)
if
UntrackedFile
.
all
.
empty?
end
end
end
end
end
end
...
...
lib/gitlab/background_migration/prepare_untracked_uploads.rb
View file @
67b58ffd
...
@@ -42,10 +42,8 @@ module Gitlab
...
@@ -42,10 +42,8 @@ module Gitlab
unless
UntrackedFile
.
connection
.
table_exists?
(
:untracked_files_for_uploads
)
unless
UntrackedFile
.
connection
.
table_exists?
(
:untracked_files_for_uploads
)
UntrackedFile
.
connection
.
create_table
:untracked_files_for_uploads
do
|
t
|
UntrackedFile
.
connection
.
create_table
:untracked_files_for_uploads
do
|
t
|
t
.
string
:path
,
limit:
600
,
null:
false
t
.
string
:path
,
limit:
600
,
null:
false
t
.
boolean
:tracked
,
default:
false
,
null:
false
t
.
timestamps_with_timezone
null:
false
t
.
timestamps_with_timezone
null:
false
t
.
index
:path
,
unique:
true
t
.
index
:path
,
unique:
true
t
.
index
:tracked
end
end
end
end
end
end
...
...
spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb
View file @
67b58ffd
...
@@ -54,12 +54,12 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :migration, :sid
...
@@ -54,12 +54,12 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :migration, :sid
expect
(
appearance
.
uploads
.
count
).
to
eq
(
2
)
expect
(
appearance
.
uploads
.
count
).
to
eq
(
2
)
end
end
it
'
sets all added or confirmed tracked files to tracked
'
do
it
'
deletes rows after processing them
'
do
expect
(
subject
).
to
receive
(
:drop_temp_table_if_finished
)
# Don't drop the table so we can look at it
expect
(
subject
).
to
receive
(
:drop_temp_table_if_finished
)
# Don't drop the table so we can look at it
expect
do
expect
do
subject
.
perform
(
1
,
1000
)
subject
.
perform
(
1
,
1000
)
end
.
to
change
{
untracked_files_for_uploads
.
where
(
tracked:
true
).
count
}.
from
(
0
).
to
(
8
)
end
.
to
change
{
untracked_files_for_uploads
.
count
}.
from
(
8
).
to
(
0
)
end
end
it
'does not create duplicate uploads of already tracked files'
do
it
'does not create duplicate uploads of already tracked files'
do
...
@@ -85,7 +85,7 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :migration, :sid
...
@@ -85,7 +85,7 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :migration, :sid
expect
(
project2
.
uploads
.
count
).
to
eq
(
0
)
expect
(
project2
.
uploads
.
count
).
to
eq
(
0
)
# Only 4 have been either confirmed or added to uploads
# Only 4 have been either confirmed or added to uploads
expect
(
untracked_files_for_uploads
.
where
(
tracked:
true
).
count
).
to
eq
(
4
)
expect
(
untracked_files_for_uploads
.
count
).
to
eq
(
4
)
end
end
it
'uses the start and end batch ids [only 2nd half]'
do
it
'uses the start and end batch ids [only 2nd half]'
do
...
@@ -103,7 +103,7 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :migration, :sid
...
@@ -103,7 +103,7 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :migration, :sid
expect
(
project2
.
uploads
.
count
).
to
eq
(
2
)
expect
(
project2
.
uploads
.
count
).
to
eq
(
2
)
# Only 4 have been either confirmed or added to uploads
# Only 4 have been either confirmed or added to uploads
expect
(
untracked_files_for_uploads
.
where
(
tracked:
true
).
count
).
to
eq
(
4
)
expect
(
untracked_files_for_uploads
.
count
).
to
eq
(
4
)
end
end
it
'does not drop the temporary tracking table after processing the batch, if there are still untracked rows'
do
it
'does not drop the temporary tracking table after processing the batch, if there are still untracked rows'
do
...
@@ -254,18 +254,6 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads::UntrackedFile do
...
@@ -254,18 +254,6 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads::UntrackedFile do
end
end
end
end
describe
'#mark_as_tracked'
do
it
'saves the record with tracked set to true'
do
untracked_file
=
create_untracked_file
(
"/-/system/appearance/logo/1/some_logo.jpg"
)
expect
do
untracked_file
.
mark_as_tracked
end
.
to
change
{
untracked_file
.
tracked
}.
from
(
false
).
to
(
true
)
expect
(
untracked_file
.
persisted?
).
to
be_truthy
end
end
describe
'#upload_path'
do
describe
'#upload_path'
do
def
assert_upload_path
(
file_path
,
expected_upload_path
)
def
assert_upload_path
(
file_path
,
expected_upload_path
)
untracked_file
=
create_untracked_file
(
file_path
)
untracked_file
=
create_untracked_file
(
file_path
)
...
...
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