Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions libs/filer/local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func (w *LocalClient) Write(ctx context.Context, name string, reader io.Reader,
flags |= os.O_EXCL
}

absPath = filepath.FromSlash(absPath)
f, err := os.OpenFile(absPath, flags, 0644)
if os.IsNotExist(err) && slices.Contains(mode, CreateParentDirectories) {
// Create parent directories if they don't exist.
Expand Down Expand Up @@ -76,7 +75,6 @@ func (w *LocalClient) Read(ctx context.Context, name string) (io.ReadCloser, err
// This stat call serves two purposes:
// 1. Checks file at path exists, and throws an error if it does not
// 2. Allows us to error out if the path is a directory
absPath = filepath.FromSlash(absPath)
stat, err := os.Stat(absPath)
if err != nil {
if os.IsNotExist(err) {
Expand All @@ -103,7 +101,6 @@ func (w *LocalClient) Delete(ctx context.Context, name string, mode ...DeleteMod
return CannotDeleteRootError{}
}

absPath = filepath.FromSlash(absPath)
err = os.Remove(absPath)

// Return early on success.
Expand Down Expand Up @@ -131,7 +128,6 @@ func (w *LocalClient) ReadDir(ctx context.Context, name string) ([]fs.DirEntry,
return nil, err
}

absPath = filepath.FromSlash(absPath)
stat, err := os.Stat(absPath)
if err != nil {
if os.IsNotExist(err) {
Expand All @@ -153,7 +149,6 @@ func (w *LocalClient) Mkdir(ctx context.Context, name string) error {
return err
}

dirPath = filepath.FromSlash(dirPath)
return os.MkdirAll(dirPath, 0755)
}

Expand All @@ -163,7 +158,6 @@ func (w *LocalClient) Stat(ctx context.Context, name string) (fs.FileInfo, error
return nil, err
}

absPath = filepath.FromSlash(absPath)
stat, err := os.Stat(absPath)
if os.IsNotExist(err) {
return nil, FileDoesNotExistError{path: absPath}
Expand Down
1 change: 0 additions & 1 deletion libs/filer/local_root_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func NewLocalRootPath(root string) localRootPath {

func (rp *localRootPath) Join(name string) (string, error) {
absPath := filepath.Join(rp.rootPath, name)

if !strings.HasPrefix(absPath, rp.rootPath) {
return "", fmt.Errorf("relative path escapes root: %s", name)
}
Expand Down