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.

45 lines
1.0 KiB

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