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
1.1 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. flag.Parse()
  20. metaStorageBackend := localfs.NewLocalfsBackend(metaDir)
  21. metaBackend := metajson.NewMetaJSONBackend(metaStorageBackend)
  22. fileBackend := localfs.NewLocalfsBackend(filesDir)
  23. files, err := metaStorageBackend.List()
  24. if err != nil {
  25. panic(err)
  26. }
  27. for _, filename := range files {
  28. metadata, err := metaBackend.Get(filename)
  29. if err != nil {
  30. log.Printf("Failed to find metadata for %s", filename)
  31. }
  32. if expiry.IsTsExpired(metadata.Expiry) {
  33. log.Printf("Delete %s", filename)
  34. fileBackend.Delete(filename)
  35. metaStorageBackend.Delete(filename)
  36. }
  37. }
  38. }