2019-05-24 09:13:01 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package mobile
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2019-11-14 19:46:15 +00:00
|
|
|
"storj.io/storj/private/fpath"
|
2019-05-24 09:13:01 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type scope struct {
|
|
|
|
ctx context.Context
|
|
|
|
cancel func()
|
|
|
|
}
|
|
|
|
|
|
|
|
func rootScope(tempDir string) scope {
|
|
|
|
ctx := context.Background()
|
|
|
|
if tempDir == "inmemory" {
|
|
|
|
ctx = fpath.WithTempData(ctx, "", true)
|
|
|
|
} else {
|
|
|
|
ctx = fpath.WithTempData(ctx, tempDir, false)
|
|
|
|
}
|
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
|
|
return scope{ctx, cancel}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (parent *scope) child() scope {
|
|
|
|
ctx, cancel := context.WithCancel(parent.ctx)
|
|
|
|
return scope{ctx, cancel}
|
|
|
|
}
|