Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Remove Deprecated Volume and ChangeDir methods. Fixes #236

## [v7.4.1] - 2025-05-05
### Security
Expand Down
33 changes: 0 additions & 33 deletions backend/azure/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@ func (l *Location) ListByRegex(regex *regexp.Regexp) ([]string, error) {
return filtered, nil
}

// Volume returns the azure container. Azure containers are equivalent to AWS Buckets
//
// Deprecated: Use Authority instead.
//
// authStr := loc.Authority().String()
func (l *Location) Volume() string {
return l.Authority().String()
}

// Authority returns the authority for the Location
func (l *Location) Authority() authority.Authority {
return l.authority
Expand Down Expand Up @@ -154,30 +145,6 @@ func (l *Location) NewLocation(relLocPath string) (vfs.Location, error) {
}, nil
}

// ChangeDir changes the current location's path to the new, relative path.
//
// Deprecated: Use NewLocation instead:
//
// loc, err := loc.NewLocation("../../")
func (l *Location) ChangeDir(relLocPath string) error {
if l == nil {
return errors.New(errNilLocationReceiver)
}

err := utils.ValidateRelativeLocationPath(relLocPath)
if err != nil {
return err
}

newLoc, err := l.NewLocation(relLocPath)
if err != nil {
return err
}
*l = *newLoc.(*Location)

return nil
}

// FileSystem returns the azure FileSystem instance
func (l *Location) FileSystem() vfs.FileSystem {
return l.fileSystem
Expand Down
54 changes: 0 additions & 54 deletions backend/azure/location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ func (s *LocationTestSuite) TestListByRegex() {
s.Equal("file2.txt", listing[1])
}

//nolint:staticcheck // deprecated method test
func (s *LocationTestSuite) TestVolume() {
fs := NewFileSystem()
l, err := fs.NewLocation("test-container", "/")
s.NoError(err)
s.Equal("test-container", l.Volume())

l, err = fs.NewLocation("another-container", "/")
s.NoError(err)
s.Equal("another-container", l.Volume())
}

func (s *LocationTestSuite) TestPath() {
l := Location{path: "/foo/bar/"}
s.Equal("/foo/bar/", l.Path())
Expand Down Expand Up @@ -150,48 +138,6 @@ func (s *LocationTestSuite) TestNewLocation_NilReceiver() {
s.Nil(nl, "An error was returned so we expect a nil location to be returned")
}

//nolint:staticcheck // deprecated method test
func (s *LocationTestSuite) TestChangeDir() {
l, err := NewFileSystem().NewLocation("test-container", "/")
s.NoError(err)
l = l.(*Location)
err = l.ChangeDir("some-dir/")
s.NoError(err)
s.Equal("/some-dir/", l.Path())

err = l.ChangeDir("path/../to/./new/dir/")
s.NoError(err)
s.Equal("/some-dir/to/new/dir/", l.Path())

l, err = NewFileSystem().NewLocation("test-container", "/")
s.NoError(err)
l = l.(*Location)
err = l.ChangeDir("/test-dir/")
s.EqualError(err, "relative location path is invalid - may not include leading slash but must include trailing slash",
"The path begins with a slash and therefore is not a relative path so this should return an error")

l, err = NewFileSystem().NewLocation("test-container", "/")
s.NoError(err)
l = l.(*Location)
err = l.ChangeDir("test-dir")
s.EqualError(err, "relative location path is invalid - may not include leading slash but must include trailing slash",
"The path does not end with a slash and therefore is not a relative path so this should return an error")

l, err = NewFileSystem().NewLocation("test-container", "/")
s.NoError(err)
l = l.(*Location)
err = l.ChangeDir("")
s.EqualError(err, "relative location path is invalid - may not include leading slash but must include trailing slash",
"An empty relative path does not end with a slash and therefore is not a valid relative path so this should return an error")
}

func (s *LocationTestSuite) TestChangeDir_NilReceiver() {
var l *Location
s.Nil(l)
err := l.ChangeDir("")
s.EqualError(err, "azure.Location receiver pointer must be non-nil")
}

func (s *LocationTestSuite) TestFileSystem() {
fs := NewFileSystem()
l := Location{fileSystem: fs}
Expand Down
31 changes: 0 additions & 31 deletions backend/ftp/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,6 @@ func (l *Location) ListByRegex(regex *regexp.Regexp) ([]string, error) {
return filteredFilenames, nil
}

// Volume returns the Authority the location is contained in.
//
// Deprecated: Use Authority instead.
//
// authStr := loc.Authority().String()
func (l *Location) Volume() string {
return l.Authority().String()
}

// Authority returns the Authority the location is contained in.
func (l *Location) Authority() authority.Authority {
return l.authority
Expand Down Expand Up @@ -196,28 +187,6 @@ func (l *Location) NewLocation(relativePath string) (vfs.Location, error) {
}, nil
}

// ChangeDir takes a relative path, and modifies the underlying Location's path. The caller is modified by this
// so the only return is any error. For this implementation there are no errors.
//
// Deprecated: Use NewLocation instead:
//
// loc, err := loc.NewLocation("../../")
func (l *Location) ChangeDir(relativePath string) error {

err := utils.ValidateRelativeLocationPath(relativePath)
if err != nil {
return err
}

newLoc, err := l.NewLocation(relativePath)
if err != nil {
return err
}
*l = *newLoc.(*Location)

return nil
}

// NewFile uses the properties of the calling location to generate a vfs.File (backed by an ftp.File). The filePath
// argument is expected to be a relative path to the location's current path.
func (l *Location) NewFile(relFilePath string, opts ...options.NewFileOption) (vfs.File, error) {
Expand Down
38 changes: 0 additions & 38 deletions backend/ftp/location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/c2fo/vfs/v7/backend/ftp/mocks"
"github.com/c2fo/vfs/v7/utils"
"github.com/c2fo/vfs/v7/utils/authority"
)

type locationTestSuite struct {
Expand Down Expand Up @@ -349,19 +348,6 @@ func (lt *locationTestSuite) TestString() {
lt.Equal("ftp://user@host.com/blah/file.txt", file.String(), "file string with user, pass, host")
}

//nolint:staticcheck // deprecated method test
func (lt *locationTestSuite) TestVolume() {
authorityStr := "user@host.com:21"
loc, err := lt.ftpfs.NewLocation(authorityStr, "/blah/")
lt.NoError(err)
lt.Equal("user@host.com:21", loc.Volume(), "Volume() should return the authority string on location.")

authorityStr = "user:password@host.com"
loc, err = lt.ftpfs.NewLocation(authorityStr, "/blah/")
lt.NoError(err)
lt.Equal("user@host.com", loc.Volume(), "Volume() should return the authority string on location.")
}

func (lt *locationTestSuite) TestPath() {
loc, err := lt.ftpfs.NewLocation("host.com", "/path/")
lt.NoError(err)
Expand Down Expand Up @@ -496,30 +482,6 @@ func (lt *locationTestSuite) TestExists() {
lt.client.AssertExpectations(lt.T())
}

func (lt *locationTestSuite) TestChangeDir() {
loc := &Location{fileSystem: lt.ftpfs, path: "/", authority: authority.Authority{}}

err1 := loc.ChangeDir("../")
lt.NoError(err1, "no error expected")
lt.Equal("/", loc.Path())

err2 := loc.ChangeDir("hello/")
lt.NoError(err2, "no error expected")
lt.Equal("/hello/", loc.Path())

err3 := loc.ChangeDir("../.././../")
lt.NoError(err3, "no error expected")
lt.Equal("/", loc.Path())

err4 := loc.ChangeDir("here/is/a/path/")
lt.NoError(err4, "no error expected")
lt.Equal("/here/is/a/path/", loc.Path())

err5 := loc.ChangeDir("../")
lt.NoError(err5, "no error expected")
lt.Equal("/here/is/a/", loc.Path())
}

func (lt *locationTestSuite) TestNewLocation() {
loc, err := lt.ftpfs.NewLocation("ftp.host.com:21", "/old/")
lt.NoError(err)
Expand Down
37 changes: 0 additions & 37 deletions backend/gs/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,6 @@ func (l *Location) ListByRegex(regex *regexp.Regexp) ([]string, error) {
return filteredKeys, nil
}

// Volume returns the GCS bucket name.
//
// Deprecated: Use Authority instead.
//
// authStr := loc.Authority().String()
func (l *Location) Volume() string {
return l.Authority().String()
}

// Authority returns the Authority for the Location.
func (l *Location) Authority() authority.Authority {
return l.authority
Expand Down Expand Up @@ -150,34 +141,6 @@ func (l *Location) NewLocation(relativePath string) (vfs.Location, error) {
}, nil
}

// ChangeDir changes the current location's path to the new, relative path.
//
// Deprecated: Use NewLocation instead:
//
// loc, err := loc.NewLocation("../../")
func (l *Location) ChangeDir(relativePath string) error {
if l == nil {
return errors.New("non-nil gs.Location pointer is required")
}

if relativePath == "" {
return errors.New("non-empty string relativePath is required")
}

err := utils.ValidateRelativeLocationPath(relativePath)
if err != nil {
return err
}

newLoc, err := l.NewLocation(relativePath)
if err != nil {
return err
}
*l = *newLoc.(*Location)

return nil
}

// FileSystem returns the GCS file system instance.
func (l *Location) FileSystem() vfs.FileSystem {
return l.fileSystem
Expand Down
47 changes: 0 additions & 47 deletions backend/gs/location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,6 @@ func (lt *locationTestSuite) TestList() {
}
}

//nolint:staticcheck // deprecated method test
func (lt *locationTestSuite) TestVolume() {
server := fakestorage.NewServer(Objects{})
defer server.Stop()
fs := NewFileSystem(WithClient(server.Client()))

bucket := "c2fo-vfs-a"
loc, err := fs.NewLocation(bucket, "/")
lt.NoError(err)
lt.Equal(bucket, loc.Volume(), "Volume() should return the bucket name on location.")
}

func (lt *locationTestSuite) TestPath() {
server := fakestorage.NewServer(Objects{})
defer server.Stop()
Expand Down Expand Up @@ -219,41 +207,6 @@ func (lt *locationTestSuite) TestExists_false() {
lt.False(exists, "Call to Exists expected to return true.")
}

func (lt *locationTestSuite) TestChangeDir() {
server := fakestorage.NewServer(Objects{})
defer server.Stop()
fs := NewFileSystem().WithClient(server.Client())

// test nil Location
var nilLoc *Location
err := nilLoc.ChangeDir("path/to/")
lt.EqualErrorf(err, "non-nil gs.Location pointer is required", "error expected for nil location")

auth, err := authority.NewAuthority("bucket")
lt.NoError(err)
loc := &Location{fileSystem: fs, prefix: "/", authority: auth}

err1 := loc.ChangeDir("../")
lt.NoError(err1, "no error expected")
lt.Equal("/", loc.Path())

err2 := loc.ChangeDir("hello/")
lt.NoError(err2, "no error expected")
lt.Equal("/hello/", loc.Path())

err3 := loc.ChangeDir("../.././../")
lt.NoError(err3, "no error expected")
lt.Equal("/", loc.Path())

err4 := loc.ChangeDir("here/is/a/path/")
lt.NoError(err4, "no error expected")
lt.Equal("/here/is/a/path/", loc.Path())

err5 := loc.ChangeDir("../")
lt.NoError(err5, "no error expected")
lt.Equal("/here/is/a/", loc.Path())
}

func (lt *locationTestSuite) TestNewLocation() {
server := fakestorage.NewServer(Objects{})
defer server.Stop()
Expand Down
23 changes: 0 additions & 23 deletions backend/mem/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,6 @@ func (l *Location) ListByRegex(regex *regexp.Regexp) ([]string, error) {
return list, nil
}

// Volume returns the volume of the current FileSystem.
//
// Deprecated: Use Authority instead.
//
// authStr := loc.Authority().String()
func (l *Location) Volume() string {
return l.Authority().String()
}

// Authority returns the authority of the current location
func (l *Location) Authority() authority.Authority {
return l.authority
Expand Down Expand Up @@ -141,20 +132,6 @@ func (l *Location) NewLocation(relLocPath string) (vfs.Location, error) {
}, nil
}

// ChangeDir simply changes the directory of the location
//
// Deprecated: Use NewLocation instead:
//
// loc, err := loc.NewLocation("../../")
func (l *Location) ChangeDir(relLocPath string) error {
err := utils.ValidateRelativeLocationPath(relLocPath)
if err != nil {
return err
}
l.name = path.Join(l.name, relLocPath)
return nil
}

// FileSystem returns the type of file system location exists on, if it exists at all
func (l *Location) FileSystem() vfs.FileSystem {
return l.fileSystem
Expand Down
Loading
Loading