summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorAndrew <write@imaginarycode.com>2017-02-10 23:00:46 -0500
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-11 12:00:46 +0800
commit42835c7f82ac379d5d583fa8406cff529b9d0e9e (patch)
tree87dc278aa0261a93b65bd06a39db7688f030a288 /modules
parentcf0f451c37496c84795e98191a20350e0f5be35c (diff)
downloadgitea-42835c7f82ac379d5d583fa8406cff529b9d0e9e.tar.gz
gitea-42835c7f82ac379d5d583fa8406cff529b9d0e9e.zip
Implement archive cleanup (#885)
* Implement archive cleanup Fixes #769 Signed-off-by: Andrew <write@imaginarycode.com> * Make sure to close the directory file * Resolve issues noted by @strk * edit cheatsheet app.ini [ci skip] * oops [ci skip]
Diffstat (limited to 'modules')
-rw-r--r--modules/cron/cron.go11
-rw-r--r--modules/setting/setting.go16
2 files changed, 27 insertions, 0 deletions
diff --git a/modules/cron/cron.go b/modules/cron/cron.go
index e1110d787b..785bf44ada 100644
--- a/modules/cron/cron.go
+++ b/modules/cron/cron.go
@@ -55,6 +55,17 @@ func NewContext() {
go models.CheckRepoStats()
}
}
+ if setting.Cron.ArchiveCleanup.Enabled {
+ entry, err = c.AddFunc("Clean up old repository archives", setting.Cron.ArchiveCleanup.Schedule, models.DeleteOldRepositoryArchives)
+ if err != nil {
+ log.Fatal(4, "Cron[Clean up old repository archives]: %v", err)
+ }
+ if setting.Cron.ArchiveCleanup.RunAtStart {
+ entry.Prev = time.Now()
+ entry.ExecTimes++
+ go models.DeleteOldRepositoryArchives()
+ }
+ }
c.Start()
}
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 1cbb3eac0a..747ddbf708 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -307,6 +307,12 @@ var (
RunAtStart bool
Schedule string
} `ini:"cron.check_repo_stats"`
+ ArchiveCleanup struct {
+ Enabled bool
+ RunAtStart bool
+ Schedule string
+ OlderThan time.Duration
+ } `ini:"cron.archive_cleanup"`
}{
UpdateMirror: struct {
Enabled bool
@@ -334,6 +340,16 @@ var (
RunAtStart: true,
Schedule: "@every 24h",
},
+ ArchiveCleanup: struct {
+ Enabled bool
+ RunAtStart bool
+ Schedule string
+ OlderThan time.Duration
+ }{
+ RunAtStart: true,
+ Schedule: "@every 24h",
+ OlderThan: 24 * time.Hour,
+ },
}
// Git settings