Contains the Concourse pipeline definition for building a line-server container
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
913 B

  1. package main
  2. import (
  3. "flag"
  4. "log"
  5. "github.com/andreimarcu/linx-server/backends/localfs"
  6. "github.com/andreimarcu/linx-server/expiry"
  7. )
  8. func main() {
  9. var filesDir string
  10. var metaDir string
  11. var noLogs bool
  12. flag.StringVar(&filesDir, "filespath", "files/",
  13. "path to files directory")
  14. flag.StringVar(&metaDir, "metapath", "meta/",
  15. "path to metadata directory")
  16. flag.BoolVar(&noLogs, "nologs", false,
  17. "don't log deleted files")
  18. flag.Parse()
  19. fileBackend := localfs.NewLocalfsBackend(metaDir, filesDir)
  20. files, err := fileBackend.List()
  21. if err != nil {
  22. panic(err)
  23. }
  24. for _, filename := range files {
  25. metadata, err := fileBackend.Head(filename)
  26. if err != nil {
  27. if !noLogs {
  28. log.Printf("Failed to find metadata for %s", filename)
  29. }
  30. }
  31. if expiry.IsTsExpired(metadata.Expiry) {
  32. if !noLogs {
  33. log.Printf("Delete %s", filename)
  34. }
  35. fileBackend.Delete(filename)
  36. }
  37. }
  38. }