mirror of
https://github.com/ZizzyDizzyMC/linx-server.git
synced 2026-01-23 02:14:33 +00:00
Update cleanup.go
This commit is contained in:
parent
6e79be6086
commit
232f4664cd
1 changed files with 15 additions and 4 deletions
|
|
@ -8,8 +8,8 @@ import (
|
|||
"github.com/andreimarcu/linx-server/expiry"
|
||||
)
|
||||
|
||||
func Cleanup(filesDir string, metaDir string, noLogs bool) {
|
||||
fileBackend := localfs.NewLocalfsBackend(metaDir, filesDir)
|
||||
func Cleanup(filesDir string, metaDir string, locksDir string, noLogs bool) {
|
||||
fileBackend := localfs.NewLocalfsBackend(metaDir, filesDir, locksDir)
|
||||
|
||||
files, err := fileBackend.List()
|
||||
if err != nil {
|
||||
|
|
@ -17,6 +17,15 @@ func Cleanup(filesDir string, metaDir string, noLogs bool) {
|
|||
}
|
||||
|
||||
for _, filename := range files {
|
||||
locked, err := fileBackend.CheckLock(filename)
|
||||
if err != nil {
|
||||
log.Printf("Error checking if %s is locked: %s", filename, err)
|
||||
}
|
||||
if locked {
|
||||
log.Printf("%s is locked, it will be ignored", filename)
|
||||
continue
|
||||
}
|
||||
|
||||
metadata, err := fileBackend.Head(filename)
|
||||
if err != nil {
|
||||
if !noLogs {
|
||||
|
|
@ -33,10 +42,12 @@ func Cleanup(filesDir string, metaDir string, noLogs bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func PeriodicCleanup(minutes time.Duration, filesDir string, metaDir string, noLogs bool) {
|
||||
func PeriodicCleanup(minutes time.Duration, filesDir string, metaDir string, locksDir string, noLogs bool) {
|
||||
c := time.Tick(minutes)
|
||||
for range c {
|
||||
Cleanup(filesDir, metaDir, noLogs)
|
||||
log.Printf("Running periodic cleanup")
|
||||
Cleanup(filesDir, metaDir, locksDir, noLogs)
|
||||
log.Printf("Finished periodic cleanup")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue