"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
drive: Finish refactor
Nick Craig-Woodb98923a20ff8
diff --git a/drive/fs.go b/drive/fs.goindex 6599efb99..a717de7c6 100644--- a/drive/fs.go+++ b/drive/fs.go@@ -41,6 +41,14 @@ import ("time")+// Pattern to match a drive url+var Match = regexp.MustCompile(`^drive://(.*)$`)++// Register with Fs+func init() {+ fs.Register(Match, NewFs)+}+// FsDrive represents a remote drive servertype FsDrive struct {svc *drive.Service // the connection to the drive server@@ -133,12 +141,9 @@ func (f *FsDrive) String() string {return fmt.Sprintf("Google drive root '%s'", f.root)}-// Pattern to match a drive url-var driveMatch = regexp.MustCompile(`^drive://(.*)$`)-// parseParse parses a drive 'url'func parseDrivePath(path string) (root string, err error) {- parts := driveMatch.FindAllStringSubmatch(path, -1)+ parts := Match.FindAllStringSubmatch(path, -1)if len(parts) != 1 || len(parts[0]) != 2 {err = fmt.Errorf("Couldn't parse drive url %q", path)} else {@@ -217,8 +222,8 @@ func MakeNewToken(t *oauth.Transport) error {return err}-// NewFsDrive contstructs an FsDrive from the path, container:path-func NewFsDrive(path string) (*FsDrive, error) {+// NewFs contstructs an FsDrive from the path, container:path+func NewFs(path string) (fs.Fs, error) {if *driveClientId == "" {return nil, errors.New("Need -drive-client-id or environmental variable GDRIVE_CLIENT_ID")}