File: gc.go

package info (click to toggle)
golang-pault-go-blobstore 0.0~git20180314.d6d187c-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 68 kB
  • sloc: makefile: 2
file content (32 lines) | stat: -rw-r--r-- 499 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package blobstore

type GarbageCollector interface {
	Find(s Store) ([]Object, error)
}

type DumbGarbageCollector struct{}

// Find {{{

func (d DumbGarbageCollector) Find(s Store) ([]Object, error) {
	linked, err := s.Linked()
	if err != nil {
		return nil, err
	}
	list, err := s.List()
	if err != nil {
		return nil, err
	}

	ret := []Object{}
	for _, node := range list {
		if _, ok := linked[node]; !ok {
			ret = append(ret, node)
		}
	}
	return ret, nil
}

// }}}

// vim: foldmethod=marker