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]
This commit is contained in:
Andrew 2017-02-10 23:00:46 -05:00 committed by Lunny Xiao
parent cf0f451c37
commit 42835c7f82
4 changed files with 92 additions and 3 deletions

View file

@ -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()
}

View file

@ -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