Shaman: more path -> filepath
Just more Windows fixes.
This commit is contained in:
parent
fe9849b134
commit
1b11233c92
@ -27,7 +27,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -175,7 +174,7 @@ func (m *Manager) EraseCheckout(checkoutID string) error {
|
|||||||
|
|
||||||
// Try to remove the parent path as well, to not keep the dangling two-letter dirs.
|
// Try to remove the parent path as well, to not keep the dangling two-letter dirs.
|
||||||
// Failure is fine, though, because there is no guarantee it's empty anyway.
|
// Failure is fine, though, because there is no guarantee it's empty anyway.
|
||||||
os.Remove(path.Dir(checkoutPaths.absolutePath))
|
os.Remove(filepath.Dir(checkoutPaths.absolutePath))
|
||||||
logger.Info().Msg("shaman: removed checkout directory")
|
logger.Info().Msg("shaman: removed checkout directory")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -210,7 +209,7 @@ func (m *Manager) SymlinkToCheckout(blobPath, checkoutPath, symlinkRelativePath
|
|||||||
|
|
||||||
logger.Debug().Msg("shaman: creating parent directory")
|
logger.Debug().Msg("shaman: creating parent directory")
|
||||||
|
|
||||||
dir := path.Dir(symlinkPath)
|
dir := filepath.Dir(symlinkPath)
|
||||||
if err := os.MkdirAll(dir, 0777); err != nil {
|
if err := os.MkdirAll(dir, 0777); err != nil {
|
||||||
logger.Error().Err(err).Msg("shaman: unable to create parent directory")
|
logger.Error().Err(err).Msg("shaman: unable to create parent directory")
|
||||||
return err
|
return err
|
||||||
|
@ -24,7 +24,6 @@ package shaman
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -119,7 +118,7 @@ func TestGCComponents(t *testing.T) {
|
|||||||
// utility mapping to be able to find absolute paths more easily
|
// utility mapping to be able to find absolute paths more easily
|
||||||
absPaths := map[string]string{}
|
absPaths := map[string]string{}
|
||||||
for absPath := range expectOld {
|
for absPath := range expectOld {
|
||||||
absPaths[path.Base(absPath)] = absPath
|
absPaths[filepath.Base(absPath)] = absPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// No symlinks created yet, so this should report all the files in oldFiles.
|
// No symlinks created yet, so this should report all the files in oldFiles.
|
||||||
@ -195,7 +194,7 @@ func TestGarbageCollect(t *testing.T) {
|
|||||||
// utility mapping to be able to find absolute paths more easily
|
// utility mapping to be able to find absolute paths more easily
|
||||||
absPaths := map[string]string{}
|
absPaths := map[string]string{}
|
||||||
for absPath := range expectOld {
|
for absPath := range expectOld {
|
||||||
absPaths[path.Base(absPath)] = absPath
|
absPaths[filepath.Base(absPath)] = absPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create some symlinks
|
// Create some symlinks
|
||||||
|
@ -49,9 +49,9 @@ func TestContains(t *testing.T) {
|
|||||||
assert.True(t, bin.contains("", filepath.FromSlash("/base/testunit/jemoeder.txt")))
|
assert.True(t, bin.contains("", filepath.FromSlash("/base/testunit/jemoeder.txt")))
|
||||||
assert.True(t, bin.contains("jemoeder", filepath.FromSlash("/base/testunit/jemoeder.txt")))
|
assert.True(t, bin.contains("jemoeder", filepath.FromSlash("/base/testunit/jemoeder.txt")))
|
||||||
assert.False(t, bin.contains("jemoeder", filepath.FromSlash("/base/testunit/opjehoofd/jemoeder.txt")))
|
assert.False(t, bin.contains("jemoeder", filepath.FromSlash("/base/testunit/opjehoofd/jemoeder.txt")))
|
||||||
assert.False(t, bin.contains("", "/etc/passwd"))
|
assert.False(t, bin.contains("", filepath.FromSlash("/etc/passwd")))
|
||||||
assert.False(t, bin.contains("/", "/etc/passwd"))
|
assert.False(t, bin.contains(filepath.FromSlash("/"), filepath.FromSlash("/etc/passwd")))
|
||||||
assert.False(t, bin.contains("/etc", "/etc/passwd"))
|
assert.False(t, bin.contains(filepath.FromSlash("/etc"), filepath.FromSlash("/etc/passwd")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilePermissions(t *testing.T) {
|
func TestFilePermissions(t *testing.T) {
|
||||||
|
@ -25,7 +25,6 @@ package filestore
|
|||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
@ -80,7 +79,7 @@ func (s *Store) MustStoreFileForTest(checksum string, filesize int64, contents [
|
|||||||
// Panics if there are any errors.
|
// Panics if there are any errors.
|
||||||
func LinkTestFileStore(cloneTo string) {
|
func LinkTestFileStore(cloneTo string) {
|
||||||
_, myFilename, _, _ := runtime.Caller(0)
|
_, myFilename, _, _ := runtime.Caller(0)
|
||||||
fileStorePath := filepath.Join(path.Dir(path.Dir(myFilename)), "_test_file_store")
|
fileStorePath := filepath.Join(filepath.Dir(filepath.Dir(myFilename)), "_test_file_store")
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
visit := func(visitPath string, info os.FileInfo, err error) error {
|
visit := func(visitPath string, info os.FileInfo, err error) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user