NewObject returns a new drive object and caches the api object
(object *drive.APIObject)
| 189 | |
| 190 | // NewObject returns a new drive object and caches the api object |
| 191 | func (f *FS) NewObject(object *drive.APIObject) Object { |
| 192 | o := Object{f, object.ObjectID} |
| 193 | f.lock.Lock() |
| 194 | f.objectCache[o.objectID] = object |
| 195 | f.lock.Unlock() |
| 196 | runtime.SetFinalizer(&o, f.removeCache) |
| 197 | return o |
| 198 | } |
| 199 | |
| 200 | // removeCache removes an unreferenced api object from the cache |
| 201 | func (f *FS) removeCache(o *Object) { |