()
| 141 | } |
| 142 | |
| 143 | func (this *FS) Close() error { |
| 144 | if this.isClosed { |
| 145 | return nil |
| 146 | } |
| 147 | |
| 148 | this.isClosed = true |
| 149 | |
| 150 | close(this.closingBChan) |
| 151 | this.syncTicker.Stop() |
| 152 | |
| 153 | var lastErr error |
| 154 | this.mu.Lock() |
| 155 | if len(this.bMap) > 0 { |
| 156 | var g = goman.NewTaskGroup() |
| 157 | for _, bFile := range this.bMap { |
| 158 | var bFileCopy = bFile |
| 159 | g.Run(func() { |
| 160 | err := bFileCopy.Close() |
| 161 | if err != nil { |
| 162 | lastErr = err |
| 163 | } |
| 164 | }) |
| 165 | } |
| 166 | |
| 167 | g.Wait() |
| 168 | } |
| 169 | this.mu.Unlock() |
| 170 | |
| 171 | err := this.locker.Release() |
| 172 | if err != nil { |
| 173 | lastErr = err |
| 174 | } |
| 175 | |
| 176 | return lastErr |
| 177 | } |
| 178 | |
| 179 | func (this *FS) TestBMap() map[string]*BlocksFile { |
| 180 | return this.bMap |