Skip to content

Commit

Permalink
Merge pull request #481 from johejo/revert-472-iofs_source_driver
Browse files Browse the repository at this point in the history
Revert "Add io/fs#FS Driver #471"
  • Loading branch information
dhui committed Nov 22, 2020
2 parents 1593164 + 67546bf commit b690b78
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 317 deletions.
27 changes: 22 additions & 5 deletions source/file/file.go
@@ -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.

0 comments on commit b690b78

Please sign in to comment.