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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
9769a870
Commit
9769a870
authored
Oct 21, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'git-archive-improvements-2' into 'master'
Clear archive cache asynchronously See merge request !1651
parents
6f5a844e
e4008bc4
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
53 deletions
+20
-53
CHANGELOG
CHANGELOG
+1
-0
app/models/repository.rb
app/models/repository.rb
+8
-8
app/services/archive_repository_service.rb
app/services/archive_repository_service.rb
+1
-1
app/workers/repository_archive_cache_worker.rb
app/workers/repository_archive_cache_worker.rb
+9
-0
app/workers/repository_archive_worker.rb
app/workers/repository_archive_worker.rb
+0
-43
spec/services/archive_repository_service_spec.rb
spec/services/archive_repository_service_spec.rb
+1
-1
No files found.
CHANGELOG
View file @
9769a870
...
...
@@ -79,6 +79,7 @@ v 8.1.0 (unreleased)
- Only render 404 page from /public
- Hide passwords from services API (Alex Lossent)
- Fix: Images cannot show when projects' path was changed
- Let gitlab-git-http-server generate and serve 'git archive' downloads
- Optimize query when filtering on issuables (Zeger-Jan van de Weg)
- Fix padding of outdated discussion item.
...
...
app/models/repository.rb
View file @
9769a870
...
...
@@ -8,6 +8,14 @@ class Repository
attr_accessor
:raw_repository
,
:path_with_namespace
,
:project
def
self
.
clean_old_archives
repository_downloads_path
=
Gitlab
.
config
.
gitlab
.
repository_downloads_path
return
unless
File
.
directory?
(
repository_downloads_path
)
Gitlab
::
Popen
.
popen
(
%W(find
#{
repository_downloads_path
}
-not -path
#{
repository_downloads_path
}
-mmin +120 -delete)
)
end
def
initialize
(
path_with_namespace
,
default_branch
=
nil
,
project
=
nil
)
@path_with_namespace
=
path_with_namespace
@project
=
project
...
...
@@ -269,14 +277,6 @@ class Repository
end
# Remove archives older than 2 hours
def
clean_old_archives
repository_downloads_path
=
Gitlab
.
config
.
gitlab
.
repository_downloads_path
return
unless
File
.
directory?
(
repository_downloads_path
)
Gitlab
::
Popen
.
popen
(
%W(find
#{
repository_downloads_path
}
-not -path
#{
repository_downloads_path
}
-mmin +120 -delete)
)
end
def
branches_sorted_by
(
value
)
case
value
when
'recently_updated'
...
...
app/services/archive_repository_service.rb
View file @
9769a870
...
...
@@ -7,7 +7,7 @@ class ArchiveRepositoryService
end
def
execute
(
options
=
{})
project
.
repository
.
clean_old_archives
RepositoryArchiveCacheWorker
.
perform_async
metadata
=
project
.
repository
.
archive_metadata
(
ref
,
storage_path
,
format
)
raise
"Repository or ref not found"
if
metadata
.
empty?
...
...
app/workers/repository_archive_cache_worker.rb
0 → 100644
View file @
9769a870
class
RepositoryArchiveCacheWorker
include
Sidekiq
::
Worker
sidekiq_options
queue: :default
def
perform
Repository
.
clean_old_archives
end
end
app/workers/repository_archive_worker.rb
deleted
100644 → 0
View file @
6f5a844e
class
RepositoryArchiveWorker
include
Sidekiq
::
Worker
sidekiq_options
queue: :archive_repo
attr_accessor
:project
,
:ref
,
:format
def
perform
(
project_id
,
ref
,
format
)
@project
=
Project
.
find
(
project_id
)
@ref
,
@format
=
ref
,
format
.
downcase
repository
=
project
.
repository
repository
.
clean_old_archives
return
unless
file_path
return
if
archived?
||
archiving?
repository
.
archive_repo
(
ref
,
storage_path
,
format
)
end
private
def
storage_path
Gitlab
.
config
.
gitlab
.
repository_downloads_path
end
def
file_path
@file_path
||=
project
.
repository
.
archive_file_path
(
ref
,
storage_path
,
format
)
end
def
pid_file_path
@pid_file_path
||=
project
.
repository
.
archive_pid_file_path
(
ref
,
storage_path
,
format
)
end
def
archived?
File
.
exist?
(
file_path
)
end
def
archiving?
File
.
exist?
(
pid_file_path
)
end
end
spec/services/archive_repository_service_spec.rb
View file @
9769a870
...
...
@@ -6,7 +6,7 @@ describe ArchiveRepositoryService do
describe
"#execute"
do
it
"cleans old archives"
do
expect
(
project
.
repository
).
to
receive
(
:clean_old_archives
)
expect
(
RepositoryArchiveCacheWorker
).
to
receive
(
:perform_async
)
subject
.
execute
(
timeout:
0.0
)
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