(fpath string, size uint64)
| 38 | type storageTypeLoop struct{} |
| 39 | |
| 40 | func (s *storageTypeLoop) Allocate(fpath string, size uint64) (storagePath string, err error) { |
| 41 | |
| 42 | if err := file.CreateFile(fpath, int64(size)); err != nil { |
| 43 | logs.Errorf("create tmp storage failed: %s", err) |
| 44 | return "", err |
| 45 | } |
| 46 | logs.Infof("finish prepare tmp storage") |
| 47 | |
| 48 | // generate loop device for tmp |
| 49 | logs.Infof("start attach loop device for tmp storage") |
| 50 | tmpDevice, err := loop.Attach(fpath, 0, false) |
| 51 | if err != nil { |
| 52 | logs.Errorf("attach tmp storage failed:", err) |
| 53 | return "", err |
| 54 | } |
| 55 | storagePath = tmpDevice.Path() |
| 56 | return storagePath, nil |
| 57 | } |
| 58 | |
| 59 | func (s *storageTypeLoop) Recycle() { |
| 60 | go recycleLoopDevice() |
nothing calls this directly
no test coverage detected