Shaman: more path -> filepath

Just more Windows fixes.
This commit is contained in:
Sybren A. Stüvel 2022-03-28 11:11:50 +02:00
parent fe9849b134
commit 1b11233c92
4 changed files with 8 additions and 11 deletions

View File

@ -27,7 +27,6 @@ import (
"fmt"
"math/rand"
"os"
"path"
"path/filepath"
"sync"
"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.
// 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")
return nil
}
@ -210,7 +209,7 @@ func (m *Manager) SymlinkToCheckout(blobPath, checkoutPath, symlinkRelativePath
logger.Debug().Msg("shaman: creating parent directory")
dir := path.Dir(symlinkPath)
dir := filepath.Dir(symlinkPath)
if err := os.MkdirAll(dir, 0777); err != nil {
logger.Error().Err(err).Msg("shaman: unable to create parent directory")
return err

View File

@ -24,7 +24,6 @@ package shaman
import (
"os"
"path"
"path/filepath"
"testing"
"time"
@ -119,7 +118,7 @@ func TestGCComponents(t *testing.T) {
// utility mapping to be able to find absolute paths more easily
absPaths := map[string]string{}
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.
@ -195,7 +194,7 @@ func TestGarbageCollect(t *testing.T) {
// utility mapping to be able to find absolute paths more easily
absPaths := map[string]string{}
for absPath := range expectOld {
absPaths[path.Base(absPath)] = absPath
absPaths[filepath.Base(absPath)] = absPath
}
// Create some symlinks

View File

@ -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("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("", "/etc/passwd"))
assert.False(t, bin.contains("/", "/etc/passwd"))
assert.False(t, bin.contains("/etc", "/etc/passwd"))
assert.False(t, bin.contains("", filepath.FromSlash("/etc/passwd")))
assert.False(t, bin.contains(filepath.FromSlash("/"), filepath.FromSlash("/etc/passwd")))
assert.False(t, bin.contains(filepath.FromSlash("/etc"), filepath.FromSlash("/etc/passwd")))
}
func TestFilePermissions(t *testing.T) {

View File

@ -25,7 +25,6 @@ package filestore
import (
"io/ioutil"
"os"
"path"
"path/filepath"
"runtime"
"time"
@ -80,7 +79,7 @@ func (s *Store) MustStoreFileForTest(checksum string, filesize int64, contents [
// Panics if there are any errors.
func LinkTestFileStore(cloneTo string) {
_, 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()
visit := func(visitPath string, info os.FileInfo, err error) error {