GetDir will retrieve data of a cached directory
(remote string)
| 169 | |
| 170 | // GetDir will retrieve data of a cached directory |
| 171 | func (b *Persistent) GetDir(remote string) (*Directory, error) { |
| 172 | cd := &Directory{} |
| 173 | |
| 174 | err := b.db.View(func(tx *bolt.Tx) error { |
| 175 | bucket := b.getBucket(remote, false, tx) |
| 176 | if bucket == nil { |
| 177 | return fmt.Errorf("couldn't open bucket (%v)", remote) |
| 178 | } |
| 179 | |
| 180 | data := bucket.Get([]byte(".")) |
| 181 | if data != nil { |
| 182 | return json.Unmarshal(data, cd) |
| 183 | } |
| 184 | |
| 185 | return fmt.Errorf("%v not found", remote) |
| 186 | }) |
| 187 | |
| 188 | return cd, err |
| 189 | } |
| 190 | |
| 191 | // AddDir will update a CachedDirectory metadata and all its entries |
| 192 | func (b *Persistent) AddDir(cachedDir *Directory) error { |