Skip to content

Revert "Add io/fs#FS Driver #471" #481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2020
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
27 changes: 22 additions & 5 deletions source/file/file.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
package file

import (
"net/http"
nurl "net/url"
"os"
"path/filepath"

"github.com/golang-migrate/migrate/v4/source"
"github.com/golang-migrate/migrate/v4/source/httpfs"
)

func init() {
source.Register("file", &File{})
}

func parseURL(url string) (string, error) {
type File struct {
httpfs.PartialDriver
url string
path string
}

func (f *File) Open(url string) (source.Driver, error) {
u, err := nurl.Parse(url)
if err != nil {
return "", err
return nil, err
}

// concat host and path to restore full path
// host might be `.`
p := u.Opaque
Expand All @@ -28,17 +37,25 @@ func parseURL(url string) (string, error) {
// default to current directory if no path
wd, err := os.Getwd()
if err != nil {
return "", err
return nil, err
}
p = wd

} else if p[0:1] == "." || p[0:1] != "/" {
// make path absolute if relative
abs, err := filepath.Abs(p)
if err != nil {
return "", err
return nil, err
}
p = abs
}
return p, nil

nf := &File{
url: url,
path: p,
}
if err := nf.Init(http.Dir(p), ""); err != nil {
return nil, err
}
return nf, nil
}
32 changes: 0 additions & 32 deletions source/file/file_go115.go

This file was deleted.

31 changes: 0 additions & 31 deletions source/file/file_go116.go

This file was deleted.

3 changes: 0 additions & 3 deletions source/iofs/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions source/iofs/doc.go

This file was deleted.

31 changes: 0 additions & 31 deletions source/iofs/example_test.go

This file was deleted.

175 changes: 0 additions & 175 deletions source/iofs/iofs.go

This file was deleted.

22 changes: 0 additions & 22 deletions source/iofs/iofs_test.go

This file was deleted.

1 change: 0 additions & 1 deletion source/iofs/testdata/migrations/1_foobar.down.sql

This file was deleted.

1 change: 0 additions & 1 deletion source/iofs/testdata/migrations/1_foobar.up.sql

This file was deleted.

1 change: 0 additions & 1 deletion source/iofs/testdata/migrations/3_foobar.up.sql

This file was deleted.

1 change: 0 additions & 1 deletion source/iofs/testdata/migrations/4_foobar.down.sql

This file was deleted.

1 change: 0 additions & 1 deletion source/iofs/testdata/migrations/4_foobar.up.sql

This file was deleted.

1 change: 0 additions & 1 deletion source/iofs/testdata/migrations/5_foobar.down.sql

This file was deleted.

1 change: 0 additions & 1 deletion source/iofs/testdata/migrations/7_foobar.down.sql

This file was deleted.

1 change: 0 additions & 1 deletion source/iofs/testdata/migrations/7_foobar.up.sql

This file was deleted.