mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
config: convert --cache-dir value to an absolute path
This commit is contained in:
@@ -63,11 +63,12 @@ func assertVolumeInfo(t *testing.T, v *docker.VolInfo, name, path string) {
|
||||
|
||||
func TestDockerPluginLogic(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
oldCacheDir := config.CacheDir
|
||||
oldCacheDir := config.GetCacheDir()
|
||||
testDir, testFs := initialise(ctx, t)
|
||||
config.CacheDir = testDir
|
||||
err := config.SetCacheDir(testDir)
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
config.CacheDir = oldCacheDir
|
||||
_ = config.SetCacheDir(oldCacheDir)
|
||||
if !t.Failed() {
|
||||
fstest.Purge(testFs)
|
||||
_ = os.RemoveAll(testDir)
|
||||
@@ -304,11 +305,12 @@ func testMountAPI(t *testing.T, sockAddr string) {
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
oldCacheDir := config.CacheDir
|
||||
oldCacheDir := config.GetCacheDir()
|
||||
testDir, testFs := initialise(ctx, t)
|
||||
config.CacheDir = testDir
|
||||
err := config.SetCacheDir(testDir)
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
config.CacheDir = oldCacheDir
|
||||
_ = config.SetCacheDir(oldCacheDir)
|
||||
if !t.Failed() {
|
||||
fstest.Purge(testFs)
|
||||
_ = os.RemoveAll(testDir)
|
||||
|
||||
@@ -41,11 +41,8 @@ type Driver struct {
|
||||
// NewDriver makes a new docker driver
|
||||
func NewDriver(ctx context.Context, root string, mntOpt *mountlib.Options, vfsOpt *vfscommon.Options, dummy, forgetState bool) (*Driver, error) {
|
||||
// setup directories
|
||||
cacheDir, err := filepath.Abs(config.CacheDir)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to make --cache-dir absolute")
|
||||
}
|
||||
err = file.MkdirAll(cacheDir, 0700)
|
||||
cacheDir := config.GetCacheDir()
|
||||
err := file.MkdirAll(cacheDir, 0700)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to create cache directory: %s", cacheDir)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user