initBackgroundUploader returns a single instance
(fs *Fs)
| 22 | |
| 23 | // initBackgroundUploader returns a single instance |
| 24 | func initBackgroundUploader(fs *Fs) (*backgroundWriter, error) { |
| 25 | // write lock to create one |
| 26 | uploaderMapMx.Lock() |
| 27 | defer uploaderMapMx.Unlock() |
| 28 | if b, ok := uploaderMap[fs.String()]; ok { |
| 29 | // if it was already started we close it so that it can be started again |
| 30 | if b.running { |
| 31 | b.close() |
| 32 | } else { |
| 33 | return b, nil |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | bb := newBackgroundWriter(fs) |
| 38 | uploaderMap[fs.String()] = bb |
| 39 | return uploaderMap[fs.String()], nil |
| 40 | } |
| 41 | |
| 42 | // Handle is managing the read/write/seek operations on an open handle |
| 43 | type Handle struct { |